Take the 2-minute tour ×
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
add comment

2 Answers 2

up vote 2 down vote accepted
%~dpn1.exe
share|improve this answer
3  
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 foo.bar see: technet.microsoft.com/en-us/library/bb490909.aspx for magic variable references. –  Tyler Apr 17 '10 at 23:48
add comment

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
add comment

Your Answer

 
discard

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.