How to Generate Directory Listing with Full Path from Batch
Sometimes you need a list of all the files and/or folders in a directory with their full path, without any additional information. “DIR /B” would be the right command, if it only printed out the full path (it does that only if combined with the recursion parameter /S).
Here is a way to print a list of full paths, in the following example of all directories in the folder “C:\Users”:
D:\>for /f "delims=" %i in ('dir /b /ad "C:\Users"') do @echo C:\Users\%i C:\Users\All Users C:\Users\Default C:\Users\Public ...
If you want files listed, replace “/ad” with “/a-d”. If you want both files and directories, use “/a”.
Thanks for this! I am sure it will be useful at some point. :)
How would I copy files driven by a directory list.
List of source files copy to target directory
Thanks – works like a champ. To populate a TXT file use >> at the end as a single > will only populate with the last directory.
for /f “delims=” %i in (‘dir /b /ad “C:\Users”‘) do @echo C:\Users\%i >> c:\temp\somefile.txt