Solved Need Help with CMD syntax

OPti3020

New member
Local time
5:08 AM
Messages
12
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 My Computer

At a glance

win7 Pro - 648gb
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Opti3020
OS
win7 Pro - 64
Memory
8gb
Browser
Vivaldi
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 :p, but I think it's a baseline for a correct solution.
 

My Computer My Computer

At a glance

Windows 7 Ultimate x64Intel Core i7-740QM8 GB DDR3NVIDIA GeForce 330GT
Computer type
Laptop
Computer Manufacturer/Model Number
Toshiba Sattelite A665-S6092
OS
Windows 7 Ultimate x64
CPU
Intel Core i7-740QM
Memory
8 GB DDR3
Graphics Card(s)
NVIDIA GeForce 330GT
Screen Resolution
1366x768
Hard Drives
Samsung 840 SSD 500GB
1TB USB3 external HD
Cooling
Coolermaster Notepal U3 notebook cooling pad
Internet Speed
3mbps ASDL
Antivirus
ClamWin 0.98.7
Browser
Opera 12.17 x86 (main), Firefox 38 (sec), IE11 (last resort)
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 My Computer

At a glance

win7 Pro - 648gb
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Opti3020
OS
win7 Pro - 64
Memory
8gb
Browser
Vivaldi
Just what does that right context menu entry do?
 

My Computers My Computers

  • At a glance

    Windows 7 pro/Windows 10 ProIntel i7 860 Quad core 2.8 ghz8 gbATI Radeon HD 5770 1 gb ram
    Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    HP Pavillion Elite HPE-250f
    OS
    Windows 7 pro/Windows 10 Pro
    CPU
    Intel i7 860 Quad core 2.8 ghz
    Memory
    8 gb
    Graphics Card(s)
    ATI Radeon HD 5770 1 gb ram
    Monitor(s) Displays
    Alienware 25 AW2521HF & Viewsonic
    Screen Resolution
    1920 x1080 & 1680x1050
    Hard Drives
    WD blue 1 tb & 500 gb.
    Browser
    FF of course.
    Other Info
    https://www.bestbuy.com/site/hp-pavilion-elite-desktop-intel-core-i7-processor-8gb-memory-1tb-hard-drive/9921493.p?skuId=9921493
  • At a glance

    Windows 2012 R2 Data center/Linux Minti3 9100 3.6GHz, 8M cache, 4C/4T8GB 2666MT/s DDR4 ECC UDIMM
    Computer type
    PC/Desktop
    System Manufacturer/Model Number
    Dell Poweredge T140
    OS
    Windows 2012 R2 Data center/Linux Mint
    CPU
    i3 9100 3.6GHz, 8M cache, 4C/4T
    Memory
    8GB 2666MT/s DDR4 ECC UDIMM
    Monitor(s) Displays
    Viewsonic
    Screen Resolution
    1680x1050
    Hard Drives
    1 TB & 750 GB
    Other Info
    https://www.dell.com/en-us/work/shop/productdetailstxn/poweredge-t140?~ck=bt
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 My Computer

At a glance

win7 Pro - 648gb
Computer type
PC/Desktop
Computer Manufacturer/Model Number
Dell Opti3020
OS
win7 Pro - 64
Memory
8gb
Browser
Vivaldi
Back
Top