I am trying to generate a text file containing the filename (including full path) and file size for all files in a particular directory and any of its sub-directories (i.e. recursively). Ideally, I don't want commas in the file size (but I'll settle for them!)
The following command does it but without the file size:
dir /b /s /a:-D > results.txt
An example output would look like:
C:\Users\Martin\Pictures\Table\original\PC120013.JPG 227298
C:\Users\Martin\Pictures\Table\original\PC120014.JPG 123234
C:\Users\Martin\Pictures\Table\original\PC120015.JPG 932344
I don't think this is possible using dir
alone, although I would love to be proved wrong.
Is there another way to do this, using only commands that are available from the Command Prompt?
Best Answer
This should do it:
It's not very efficient...running it for folders containing a ton of files may be sketchy, so try it on small folders first.
From the "for /?" help text (I used 'a' instead of 'I')