In file management and data-management there are times when it is required to get a complete listing in a text file or database file containing all file paths of files in a directory, possibly including sub-directories. This can be used for a variety of uses such as general internal correspondence or records to assist in file organization or re-organization planning to create a table of info with links or paths to related documents/images to save time on database manual input methods and loads more.
My inspiration to write this article arrose with the task of importing a few thousand products to a website database, and importing the image file paths was a life-saver on the encoding time required!
There are two options I've found helpful in Windows the first being simpler but less detailed results. The second of which can be used for large folder and sub-directory structures optionally with further information. These require no installation of any software and work in Windows Vista and Windows 7 Windows 8/8.1 and Windows 10 and assume you know some basics in Windows!:
The easy way to get your file list in windows:
- Using Windows Explorer navigate to the folder that contains all the items you need listing.
- Select all the contents of that folder with the mouse or by pressing "Ctr + A".
- Hold the Shift key and right click on your selected files. Click on "Save as Path".
- Now go to your document text file or spreadsheet program and paste it where you need the info.
- You should see it has pasted the full path of each file which was selected within that folder.
The Disadvantage of this method is that it will not list files in sub-directories and only lists other folder names inside your top level directory/folder without telling you what's inside! To get this detail if it's required, you'll need to go a little deeper into the depths of windows Command Prompt.
The harder but detailed Results file list in windows:
In Windows Vista/7/8/8.1 click on the "start" button and in the text box type in the search "cmd". Right click "cmd.exe" which should be the first result and select "run as administrator". Windows 10 users, right click the windows icon menu bottom left, select "Command Prompt (Admin)".
Navigate to the top level folder you need the details from. To navigate in the Command Prompt to go up a folder level type "cd .." and to go down a level type "cd foldername" where "foldername" is the next folder you want to be in. If you are getting lost you can always type "dir" which will list the directories inside where you are currently at. More details about navigating in the command prompt can be found on google.
When you are in the top level you want to list the contents of (even if it's your hard drive!) type the following:
DIR /S /B >filelist.txt
The last part of the above command tells the function to output the list to a text file called "filelist.txt" in the folder you are at. In the above case the "/S" tells the function to include sub-directories and the "/B" tells the function to use a bare simple format (no heading or summary per sub-directory). There are alternative commands you can use to change the output of this function however if you want a simple list of file paths not grouped by sub-directory with header or date info be sure to include the "/B". To see a list of alternative or additional commands for the the DIR function type "DIR /?" to see a list with all the options.
The same above command can be written to a csv file if you want to open the information directly in a spreadsheet program and save it from there. Simply change the above command to the following:
DIR /S /B >filelist.csv
The output file paths are complete and will include your hard drive.
If you receive any sort of warning such as "Access Denied" be sure you are using an admin account with access privilages to the directories you are analysing. If you were analysing the main hard drive and did not open the command prompt as an administrator you will need to close it and follow the first part of this guide ensuring you are able to run CMD as an administrator. Consult the administrator if you are not the one!
Hope the above helps some-one! I found the alternative freeware / shareware and software available for a price did not give me any more advantage I required to the above techniques!