1

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).

1

1 Answer 1

0

I found the solution myself:

"cmd.exe /C For %%A in (%1) do (echo %%~nxA >> %%~nA.txt)"
1
  • Welcome to Super User! Thank you for closing the loop and answering your own question. To help other folks understand your solution, could you edit your answer and add an explanation? Cheers!
    – bertieb
    Commented Feb 27, 2019 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .