Need Help with CMD syntax


  1. Posts : 9
    win7 Pro - 64
       #1

    Need Help with CMD syntax


    Hi,

    I added a new entry to my Context Menu: "DIR List Here" which works fine except that it writes the Dir_List.txt to the parent folder of the one i'm focused on rather than in the focused folder itself. This is the command:
    Code:
    "cmd /c dir "%L" /a /b /-p /o:gen >  Dir_List.txt"
    What's wrong with my syntax? How can I get this to put the file in the focused folder?
      My Computer


  2. Posts : 2,468
    Windows 7 Ultimate x64
       #2

    Not "exactly" tested, but I think the file is written to the "current" folder, which is, the one in which is opened in Windows Explorer, not surprisingly, the parent of the one you're clicking.

    You can solve it by specifing the full path in the destination file. Given that you already have the path of the target folder in the %L variable, you can state it by something like this.

    Code:
    cmd /c dir "%L" /a /b /-p /o:gen >  "%L\Dir_List.txt"
    Note that in the last bit I've added %L to the output file.
    Again, not tested , but I think it's a baseline for a correct solution.
      My Computer


  3. Posts : 9
    win7 Pro - 64
    Thread Starter
       #3

    It Worked!!

    Thank you very much, Alejandro !!!

    Since it's working i'll share with any of you who would like to add a command to the right click (context) menu whenever you click on a folder in your file manager. It's only 4 lines of reg code but I find it very handy.

    Code:
    Windows Registry Editor Version 5.00
    
    ;; note: this creates a list of files & folders only - if you want dates, sizes, etc delete the "/b"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\FileListing]
    @="Create DIR List Here"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\FileListing\command]
    @="cmd /c dir "%L" /a /b /-p /o:gen >  "%L\"Dir_List.txt"
    Just copy the code into a new file with a .reg file extension and merge it.

    If you don't like it just put a dash between the [ and the HKEY for both keys and re-merge the reg file.
      My Computer


  4. Posts : 1,851
    Windows 7 pro
       #4

    Just what does that right context menu entry do?
      My Computer


  5. Posts : 9
    win7 Pro - 64
    Thread Starter
       #5

    Well, DUH, it might have been better to explain that - wouldn't it!

    What this does is allow you to have a quick & easy way to get a printable / copy-able list of the files & folders in the folder you're looking at.

    -- right click on the folder in question
    -- click on "Create DIR List Here" in the Context menu
    -- a text file titled DirList.txt will be written the the folder that lists all of the files / folders in alphabetical order - folders first.

    note: if you want "complete" folder info with all of the dates / sizes / etc then delete the "/b" from the regfile - saving it, of course, and then merge it into the registry.
      My Computer


 

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

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