PowerShell Newbie Question

Welcome Forums General PowerShell Q&A PowerShell Newbie Question

Viewing 3 reply threads
  • Author
    Posts
    • #204846
      Participant
      Topics: 3
      Replies: 5
      Points: 33
      Rank: Member

      Dear All,

      Excuse my lack of experience. I am trying to generate a text file that includes all files that end with ‘*.txt’ from the whole HARD-DRIVE, using Mac

      my command looks like the following:

      Get-ChildItem -Path “./” -Recurse -Name -Include ‘*.txt’ | Out-File “./Desktop/JUNK/HD-Files.txt”

      It works very well and very fast but my problem is the ‘-recurse’ commant which doesn’t stop on my terminal I always end up stopping the command myself.

      Anybody knows how I can solve that on the command-line itself?

       

      I would appreciate the help!

       

      Regards,

      Mido

    • #204873
      Participant
      Topics: 12
      Replies: 1623
      Points: 2,565
      Helping Hand
      Rank: Community Hero

      Recursion is going to look for files in every directory at every depth, so when you say it doesn’t stop, what exactly does that mean? 10 minutes, 2 hours? Are you seeing a file created with the file information?

      The only thing that I would recommend is that you create a csv rather than a text file. Powershell will return an object, which is more of a table.

      Get-ChildItem -Path “./” -Recurse -Name -Include ‘*.txt’ | Export-CSV “./Desktop/JUNK/HD-Files.csv” -NoTypeInformation
      
    • #204876
      Participant
      Topics: 4
      Replies: 2249
      Points: 5,494
      Helping Hand
      Rank: Community MVP

      Hmmm … I do not have a Mac so I’m not able to reproduce but you might elaborate a little more what’s your problem.

      If you start Get-ChildItem in the root and tell it to -Recurse it will only stop if it has searched each and evetry single folder on the drive. It might just take a little longer … did you try to wait a little longer?

    • #204933
      Participant
      Topics: 3
      Replies: 5
      Points: 33
      Rank: Member

      Hmmm … I do not have a Mac so I’m not able to reproduce but you might elaborate a little more what’s your problem.

      If you start Get-ChildItem in the root and tell it to -Recurse it will only stop if it has searched each and evetry single folder on the drive. It might just take a little longer … did you try to wait a little longer?

      Recursion is going to look for files in every directory at every depth, so when you say it doesn’t stop, what exactly does that mean? 10 minutes, 2 hours? Are you seeing a file created with the file information?

      The only thing that I would recommend is that you create a csv rather than a text file. Powershell will return an object, which is more of a table.

      <textarea class=”ace_text-input” style=”opacity: 0; height: 18px; width: 7.2246875px; left: 45px; top: 0px;” spellcheck=”false” wrap=”off”></textarea>

      1
      2
      Get-ChildItem Path “./Recurse Name Include*.txt| Export-CSV “./Desktop/JUNK/HD-Files.csvNoTypeInformation
      XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

      I appreciate your reply! Indeed I got used to PS being fast even with large data, which is why I haven’t given it enough time apparently. But now after you suggested to do that, it actually worked and it stopped by itself.

       

      Thank you very much!

      Regards,

      Mohamed.

Viewing 3 reply threads
  • The topic ‘PowerShell Newbie Question’ is closed to new replies.