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 Answers 2

2
%~dpn1.exe
1
  • 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, 2010 at 23:48
0

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

1
  • Please, read again, I tried to explain more clearly. Apr 17, 2010 at 11:43

You must log in to answer this question.

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