Execute a command for all files in a folder

2019-02-25 05:51发布

问题:

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.

回答1:

Try this:

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

Start in the folder with the *.ajt files.