Small Batch File to get a list of files in a certain directory.

If you have ever needed to get a simple list of files in a particular folder from a command line or batch file, here is a small batch file that should work for you.

Create a text file named filelisting.bat. In that file copy the following line of text
dir C:\folder\that\you\choose /a /b /-p /o:n > file-listing.txt

You must change the "C:\folder\that\you\choose" to an actual directory. You can also change the output "file-listing.txt" to contain a full path if you want the file to be created in a different location. This will create a simple list sorted by filename of the files in the folder you specify

This small batch file could come in handy if you would like to run the output of this file through some other type of script that could contain a loop that loops through each filename listed inĀ file-listing.txt. This script could be set up to FTP files or to archive files, really whatever you can think of.

For more command line articles click here

Labels: , ,