'use powershell to print a list of files inside a folder and its subfolders
i need to print all the files included in a folder and its subfolders. i tried with this command
Get-ChildItem -Path 'c:\mypath\' -File -Recurse | Out-File -FilePath 'c:\mypath\files.txt'
If i run the first part alone, i get the result in powershell with no errors, but if i run the full line, i get the following error
Get-ChildItem : The tag present in the reparse point buffer is invalid.
At line:1 char:1
+ Get-ChildItem -Path 'C:\Users\XXX ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ReadError: (C:\Users\XXXX:String) [Get-ChildItem], IOExcep
tion
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
how to fix? is there also a way to print only the files with their path in the same line? I'd need a file in a similar format
filename size lastEdited path
thank you so much
Solution 1:[1]
In order to get it into the format requested you just need to use select-object to choose the items of interest:
Get-ChildItem -Path 'c:\mypath\' -File -Recurse |
select-object name,length,lastwritetime, fullname |
out-file 'c:\mypath\files.txt'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Itchydon |
