Reputation: 703
Windows Command Line (or maybe PowerShell).
How can I list all files, recursively, with full path and filesize, but without anything else and export to a .txt file. Much preferably a code that works for whichever current directory I am in with the Command Line (so does not require manual entering of the target directory).
None of these provides path\filename and filesize only:
dir /s > filelist.txt
dir /s/b > filelist.txt
dir /s/o:-d > filelist.txt
Desired output (fullpath\file.ext filesize):
c:\aaa\file.ext 7755777
c:\aaa\bbb\1.txt 897667
c:\aaa\bbb\2.ext 67788990
c:\aaa\bbb\nnn\a.xls 99879000
Upvotes: 23
Views: 85845
Reputation: 306
OP's chosen answer using PowerShell (and their comment that they used Get-ChildItem -Recurse | select Length,LastWriteTime,FullName | Format-Table -Wrap -AutoSize | Out-File filelist.txt
) was almost what I wanted for processing in Excel. Thanks for that part.
Unfortunately, (as they mentioned) the output had wrapped lines for long file paths, which isn't quite what I wanted.
The following command will produce a CSV formatted file (no wrapped lines):
Get-ChildItem -Recurse | select Length,LastWriteTime,FullName | Export-Csv -path filelist.csv -NoTypeInformation
Kudos to https://stackoverflow.com/a/23434457/7270462 for the tip about Export-Csv
Upvotes: 6
Reputation: 1
Go to folder and shift+Right Click
---> Powershell and then put in this code.
gci -rec -file|%{"$($_.Length)~$($_.Name)~$($_.FullName)"} >filelist.txt
Ctrl+A
then Ctrl+C
---> Copy into Excel
Upvotes: 0
Reputation: 11
The following removes the wrapping issue you have:
Get-ChildItem -Recurse | select Length,LastWriteTime,FullName | Format-Table -Wrap -AutoSize | out-string -width 4096 | clip
Have a look at this Reference.
Upvotes: 1
Reputation:
PowerShell:
gci -rec -file|%{"$($_.Fullname) $($_.Length)"} >filelist.txt
earlier PowerShell versions:
gci -rec|?{!$_.PSIsContainer}|%{"$($_.Fullname) $($_.Length)"} >filelist.txt
Batch file:
(@For /F "Delims=" %%A in ('dir /B/S/A-D') Do @Echo %%~fA %%~zA) >filelist.txt
Cmdline
(@For /F "Delims=" %A in ('dir /B/S/A-D') Do @Echo %~fA %~zA) >filelist.txt
Upvotes: 15
Reputation: 718
Get-ChildItem -Recurse | select FullName,Length | Format-Table -HideTableHeaders | Out-File filelist.txt
Upvotes: 13