top of page

dir command to target folder

Some great code for a Windows batch file was posted here, which will allow you to very easily run the Windows dir command on any folder.

Enter this code in a text file and then save the file with the extension '.bat'.


SET targetPath="%~1"

SET ToolPath=%~dp0

dir %targetPath% /b /s /a-d > "%ToolPath%list.txt"

Then select the folder whose contents you want a list of and drag it from one Windows Explorer window into a different one in which the bat file is saved.

A new text file will be generated that lists the contents of the folder (and any subfolders). The full path to each file is listed - there is no other content.

bottom of page