-1

I have a folder which freezes the whole system when I open it (probably there is a corrupted file). Luckily, I'm just interested in the names of the files in the folder.

So, how do I create a dirlist.txt from a folder in Powershell and at the same time not save it in the folder itself? Because if I do that, I won't be able to reach the dirlist. Thanks a lot!

2 Answers 2

0

Just pipe the output to a particular folder. Using the PowerShell or old CMD prompt.

dir "c:\program files"> c:\junque\mystuff.txt

will list the contents of the C:\Program Files folder and, assuming the folder C:\junque exists and that you have access to it, list the files in the document mystuff.txt.

0
Get-ChildItem C:\folder\ | Out-File C:\dirlist.txt

The first path is the folder you want to get the items of. You can also add the -Recurse flag if there are subfolders you'd like to get the items of.

1
  • I'd add the parameter -ErrorAction SilentlyContinue or short -EA 0 to the gci.
    – LotPings
    Commented Jun 18, 2018 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .