0

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?

2
%~dpn1.exe
  • 4
    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
0

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

  • Please, read again, I tried to explain more clearly. – Simon Perepelitsa Apr 17 '10 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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