Wednesday, January 25, 2017

Explorer context menu command: Take source filename and add it to new text file

I'm looking to add a menu item to Windows Explorer context menu for a certain file extension - for the purpose of this example let's say for MP3 files.
Upon rightclicking the file and selecting the menu item I want a command to be executed:
- Take filename and extension (but without the file path) of the file and add that to a new text file which is named the same.


Here's where I'm at with the registry file:


[HKEY_CLASSES_ROOT\SystemFileAssociations\.mp3\shell\Create Text File\command]
@="cmd.exe /C echo #filenameWithoutPath.mp3# >> #filename.txt#"

The ## indicates where I am blank. What I can't figure out is to build the command to take the filename of the selected file and add that with extension to a new text file of the same name.


I am almost there with this:


"cmd.exe /C echo %1 >> %1.txt"

However with this, the filename including path is entered to the file, and the output file name gets double extension (.mp3.txt).

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...