Solved Need Help with CMD syntax

OPti3020

New member
Local time
4:41 PM
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

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

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

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

System One System Two

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

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