I'd like to generate a list with *only* file names


  1. Posts : 6
    Windows 10
       #1

    I'd like to generate a list with *only* file names


    - Winkey, “cmd”
    - “cd e:\media\trainingvids”
    - “dir *.* /s /b /a -d > c:\temp\dork.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 (\temp) 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
    Last edited by FoxyBoxOfRox; 03 Jan 2016 at 16:10.
      My Computer


  2. Posts : 2,790
    Linux Mint 20.1 Win10Prox64
       #2
      My Computer


  3. Posts : 61,859
    64-bit Windows 11 Pro for Workstations
       #3

    Hello FoxyBoxOfRox, and welcome to Ten Forums. :)

    You might also see if the context menu below may be able to help with this.

    Context Menu - Add View and Print File Directory
      My Computers


  4. Posts : 6
    Windows 10
    Thread Starter
       #4

    Still Open


    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!
      My Computer


  5. Posts : 13,955
    Windows 10 Pro X64 21H1 19043.1503
       #5

    I think you need to pipe the output of dir to a file then read it with the batch FOR command:

    See here: Batch Script Parsing Dir Command
      My Computers


  6. Posts : 6
    Windows 10
    Thread Starter
       #6

    Solved


    Thanks Ztruker. The boys over there at StackOverflow solved 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 Document file and name it whatever you want, and locate it wherever you want, but you have to change the .txt file extension to .bat for 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 .pdf if you want an inventory of just the PDF files. Or .mp3 if you just want those music files, etc. Any file type you want an inventory of.

    Code:
    @echo off
    > "C:\temp\dork.txt" (
        for /F "eol=| delims=" %%F in ('
            dir /B /S /A:-D "E:\media\trainingvids\*.*"
        ') do (
            echo(%%~nxF
        )
    )
      My Computer


  7. Posts : 13,955
    Windows 10 Pro X64 21H1 19043.1503
       #7

    Good, glad you got it working.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 19:06.
Find Us




Windows 10 Forums