Dumping Files Names from MS Windows Directory
I hate the MS Windows command shell. Maybe it is because I am not well versed in it or maybe it is just because I am lazy. Not sure. Either way, I wanted to find a nice way to create a list of all the files in a directory and put it into a file. But, as I was working in Windows I didn’t want to open a command shell to get it done. In steps Microsoft KB371379: How to add the Print Directory feature for folders in Windows XP and in Windows Vista. This is a handy little feature that would send the directory listing directly to the default printer simply by right clicking on the folder and selecting “Print Directory Listing.”
Now, printing directly to the default printer might be fun for some, but it is not what I had in mind. So, I modified the batch script a little.
@echo off
date /t > %2
time /t >> %2
echo. >> %2
dir %1 /b /-p /o:gn >> %2
exit
This adds a file to the specified directory. This file includes a date/time stamp (accurate to a minute) and a plan file listing that does not include any other information. I find this helpful for quickly including things in notes and reports and I hope that it helps you as well.
Go forth and do good things,
Don C. Weber
Help support my training and travel to security conferences. Get your SANS Training and GIAC Certifications through the Security Ripcord.
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.









September 29th, 2008 at 8:41 pm
[...] Security Ripcord >> Blog Archive >> Dumping Files Names from MS Windows Directory Nifty batch file to get a list of files in a directory. Very nice when hooked up to the context sensitive menu as suggested in the article. Slight modification to write to new media would make it handy for forensics too. [...]
October 9th, 2008 at 10:00 pm
Used your script in conjunction with MS KB371379, and all went well. BUT where is the file put that the script creates?
Have searched hard drives, but cannot find it anywhere. The option is on the folder ‘right click’ as it should be, the screen flicks briefly when the script runs, but then ….????
Can you help please?
Regards,
Richard
December 4th, 2008 at 2:35 am
@Richard,
I apologize for not getting this out there sooner. I have been very busy lately.
I assure you that I did test this before putting it up. It appears, however, that I made a mistake somewhere along the way. I have updated the code in the post so that it works.
Hope it helps,
Don C. Weber