1

I am trying to create a batch file for a project, which reads through the files in a directory and runs a command for each file that manipulates a file in some way (from another program). While running the program, it saves each manipulated file to an output folder, with the extension "_updated". How can I do this in my command using a batch file without the extension of the file becoming a part of the file name? for instance, the o/p goes from "Videoa.bin" to "Videoa.bin_updated.bin". How can I fix this? Code below!

@ECHO ON

cd [filename]
SET v=output_folder
mkdir %v%

for %%a in ([path to files]*\.bin) do [command, which takes in the following args: 
                                       output file name (the one with the _updated ext),
                                       and input folder(+more)]

PAUSE
aschipfl
  • 33,626
  • 12
  • 54
  • 99

1 Answers1

0

I suppose you are looking at something like this, the following will only echo the new modified filename..

@echo off
set "input=D:\input_folder\"
SET "output=C:\output_folder\"
mkdir %output% > nul 2>&1
for %%a in ("%input%*.bin") do echo "%%~na_update.%%~xa"

So the original filename will be %%a name of file only will be %%~na and extension only will be %%~xa

For more on this, I suggest you run the help to see detail about variable expansion.

  • for /?

As for the other command portions you have mentioned, I do not know anything about it as you have not specified any detail about it, so you would need to figure out how it will fit the above code, or edit your question and show a bit more detail about how you manually run the command for help on automating it.

Gerhard
  • 22,678
  • 7
  • 27
  • 43