Page 1 of 1
File list using DIR
Posted: 02 Nov 2013 08:14
by highandwild
I'm trying to output, to a text file, a list of files in a folder and its sub-folders in a one line per file format with
date, size and folder name.
I've fiddled around with various switches but I have not got there yet.
Any ideas anybody?
Thanks
Re: File list using DIR
Posted: 02 Nov 2013 08:57
by aGerman
Run DIR in a FOR /F loop and use the modifiers of FOR variables to expand them to the data you need.
Code: Select all
for /f "delims=" %%i in ('dir /a /b /s "c:\your\folder"') do echo "%%~nxi" %%~ti %%~zi "%%~dpi"
Regards
aGerman
Re: File list using DIR
Posted: 02 Nov 2013 09:09
by foxidrive
+1 but use /a-d instead of /a in the dir command, to eliminate folders.
Re: File list using DIR
Posted: 02 Nov 2013 10:52
by highandwild
Thanks for this.
Where do I insert the file name in which I would llke the listing saved?
Thanks
Re: File list using DIR
Posted: 02 Nov 2013 12:46
by Squashman
highandwild wrote:Thanks for this.
Where do I insert the file name in which I would llke the listing saved?
Thanks
Redirect the output of aGerman's code to a text file.
You can read about redirecting output here.
http://www.robvanderwoude.com/redirection.php
Re: File list using DIR
Posted: 27 Nov 2013 23:54
by shayanjameel08
The only other thing I saw was "FindFileFirst", but I can't seem to get that to work at all.
So, my question is, how do I get the names of folders using "Dir()"?