Calvin Carson
Calvin Carson

Reputation: 31

Execute a command for all files in a folder

I want to run a command on all files in a directory. For %%1 in (c\conversion*.ajt) do convert command %%1 %%2 However I need to have an output filename the same as the input but with a different file extension.

asciitojt.exe filename1.ajt filename1.jt 
asciitojt.exe filename2.ajt filename2.jt 
asciitojt.exe filename3.ajt filename3.jt 

is what I want to get out of the system.
How do I replace the last 3 characters? This is to run in a batch file.

Upvotes: 3

Views: 3236

Answers (1)

Endoro
Endoro

Reputation: 37569

Try this:

for %%i in (*.ajt) do "asciitojt.exe" "%%~i" "%%~ni.jt"

Start in the folder with the *.ajt files.

Upvotes: 3

Related Questions