Welcome › Forums › General PowerShell Q&A › PowerShell Newbie Question
- This topic has 3 replies, 3 voices, and was last updated 11 months, 1 week ago by
Participant.
-
AuthorPosts
-
-
February 20, 2020 at 9:01 am #204846
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
-
February 20, 2020 at 1:37 pm #204873
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.
PowerShell1Get-ChildItem -Path “./” -Recurse -Name -Include ‘*.txt’ | Export-CSV “./Desktop/JUNK/HD-Files.csv” -NoTypeInformation -
February 20, 2020 at 1:39 pm #204876
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?
-
February 20, 2020 at 4:21 pm #204933
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>12Get-ChildItem –Path “./” –Recurse –Name –Include ‘*.txt’ | Export-CSV “./Desktop/JUNK/HD-Files.csv” –NoTypeInformationXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXI 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.
-
-
AuthorPosts
- The topic ‘PowerShell Newbie Question’ is closed to new replies.