HOW TO KNOW IF SOME FAILS ARE INTO SPECIFIC FOLDER

Welcome Forums General PowerShell Q&A HOW TO KNOW IF SOME FAILS ARE INTO SPECIFIC FOLDER

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 week, 1 day ago.

  • Author
    Posts
  • #176719

    Participant
    Topics: 3
    Replies: 4
    Points: 43
    Rank: Member

    Good morning All,

    I am a beginner in PowerShell, and I would like to ask you the following:

    I copy a bunch of files (.zip) into a specific INCOMING folder, then they are converted to .7z files and then they are moved to an ARCHIVE folder (.7z), if all the process was OK, then the files are moved to another folder (IMPORTED), But, if some of the files for some reason fail, then they are moved to a FAILED folder.
    My question is I need to know how many of them went to the IMPORTED folder and/or how many of them went to the FAILED folder and how many of them are in the ARCHIVE folder.
    Many thanks in advance.

  • #176725

    Participant
    Topics: 1
    Replies: 1530
    Points: 2,591
    Helping Hand
    Rank: Community Hero

    Could you please show the code you arleady wrote? Thanks

    Actually you just need to do a Get-ChildItem for each of your desired folders and count the files you get.

    • #176872

      Participant
      Topics: 3
      Replies: 4
      Points: 43
      Rank: Member

      Hi Olaf, Many thanks for your reply.

      The code is:

      $Failed = "D:\LPStorage\Fail\*"
      $Archive = "D:\LPStorage\Archive\*"
      (Get-ChildItem -include *.zip -Path $Failed).Count
      (Get-ChildItem -include *.7z -Path $Archive).Count

      Many thans again.

       

You must be logged in to reply to this topic.