Saturday, August 5, 2017

windows - Print the file name with another extension (Batch-program)


Batch-program launchs with 1 parameter (full path to file)


program.cmd "C:\Path\To\File\Filename.txt"

Now, this program consists of 1 command:


echo %1

And it just prints an argument: C:\Path\To\File\Filename.txt for the upper example.


But I want it to print an argument (full path) with another extension, e.g. .exe. For the upper example, I want it to print C:\Path\To\File\Filename.exe.


How to make it do that?


Answer



%~dpn1.exe

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