Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted
share|improve this answer
This answer works, but it's not particularly descriptive. Use of the tilde magic variables would be echo %dpn1.ext you could also do echo %dpn1.%2 and then use changeext.bat foo.txt bar and have the output see: for magic variable references. –  Tyler Apr 17 '10 at 23:48

In your program.cmd, you can just write commands as you would normally use them at the command prompt.

share|improve this answer
Please, read again, I tried to explain more clearly. –  Semyon Perepelitsa Apr 17 '10 at 11:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.