- Winkey, “cmd”
- “cd e:media rainingvids”
- “dir *.* /s /b /a -d > c: empdork.txt”
So, with that I'm opening a command prompt, changing to the correct directory, doing a directory listing of all files (including sub-directories (/s), no headers or footers so 'bare' format (/b), and trying to NOT display the directory (/a -d) – and then sending/piping that (>) to a file I've designated to be named and created (dork.txt) in a temporary directory ( emp) that already exists on my c:.
The problem is that it doesn't work. I'm not able to find a way to NOT include the full path along with the file names. I want a resultant file that JUST has the full file names, and could use some quick help with syntax, or maybe I've got it all wrong and it can't be done in this way.
I need the process to work for both Windows 10 and Windows 7 machines, so hopefully there is no difference in the DOS syntax between the two, as I know there were slight differences with much older DOS versions.Of course, if there are sexy new ways to achieve this list in Windows 10, I'm all ears.
Reference:
- dir (command) - Wikipedia, the free encyclopedia
You can try this:
Hello FoxyBoxOfRox, and welcome to windowssh blog.
You might also see if the context menu below may be able to help with this.
Context Menu - Add View and Print File Directory
Thank you everyone, but I'm going to change my request to DOS only. I need a batch file to work.
And using batch files with Basic code is still a function available within Windows 10, so I don't believe I'm off-topic.
Thank you in advance, if anyone can help me get this syntax sorted!
I think you need to pipe the output of dir to a file then read it with the batch FORcommand:
See here: Batch Script Parsing Dir Command
Thanks Ztruker. The boys over there at StackOverflowsolved it for me. (You have to use a For loop.)
To those that come across this thread: just right-click and create a new Text Documentfile and name it whatever you want, and locate it wherever you want, but you have to change the .txtfile extension to .batfor it to run (e.g. GetFileNames.bat), and paste the DOS Basic code below into it. Change the directory values in the code as needed, and also whatever resultant inventory file name you want. Double click on your new Batch file from within Explorer to generate the new inventory text file (e.g. dork.txt -or- name it FileInventory.txt).
Each time you run the Batch file, the old inventory file will be overwritten, so you'll have to move it first, or just rename it, if you want the old inventory values.
Also note that you can change the *.*value to .pdfif you want an inventory of just the PDF files. Or .mp3if you just want those music files, etc. Any file type you want an inventory of.Code:@echo off > "C: empdork.txt" ( for /F "eol=| delims=" %%F in (' dir /B /S /A:-D "E:media rainingvids*.*" ') do ( echo(%%~nxF ) )
Good, glad you got it working.