OK, I guess you have a bunch of files like
ant.mov
bug.mov
cat.mov
dog.mov
︙
in a directory (a.k.a. folder), and you want to do
HandBrakeCLI.exe (blah blah blah) -i ant.MOV -o ant.mp4
HandBrakeCLI.exe … … -i bug.MOV -o bug.mp4
HandBrakeCLI.exe … … -i cat.MOV -o cat.mp4
HandBrakeCLI.exe … … -i dog.MOV -o dog.mp4
︙
for all the *.mov files.
This is fairly straightforward:
for %F in (*.mov) do HandBrakeCLI.exe (blah blah blah) -i "%F" -o "%~nF.mp4"
The for %F in (*.mov) runs a loop
in which %F takes on every applicable *.mov name.
Then the command following the do is executed for each file,
with %F obviously being replaced by the .mov file name.
(Note: the F is case sensitive.)
(You might be able to get by without the quotes —
i.e., say just %F, and not "%F" —
but then it will fail if you have any filenames
with space(s) or other special characters in them.)
%~nF is replaced by the name portion of the filename
(not including the extension), so %~nF.mp4 becomes your output filename.
You may want to break this into multiple lines,
because your actual command is so long,
and/or because you want to do other things in the loop.
You can do this with parentheses:
for %F in (*.mov) do (
HandBrakeCLI.exe (blah blah blah) -i "%F" -o "%~nF.mp4"
(other command(s) featuring "%F", "%~nF", etc.)
)
Type for /? to see a list of all the ~ codes.
(For example, %~dF gives you the drive letter, and %~pF gives you the path.
The documentation is not clear about the fact
that you can combine the modifiers;
e.g., %~dpnF gives you the drive, the path, and the name,
but not the extension — as if you had typed %~dF%~pF%~nF.)
You can also break long commands into multiple lines with ^:
for %F in (*.mov) do (
HandBrakeCLI.exe --preset-import-file "preset-name.json" ^
-Z "preset-name" -i "%F" -o "%~nF.mp4"
(other command(s) featuring "%F", "%~nF", etc.)
)
All of the above works at the Command Prompt (command line).
The same thing works in a batch script,
except you must replace each % with %%:
for %%F in (*.mov) do (
HandBrakeCLI.exe --preset-import-file "preset-name.json" ^
-Z "preset-name" -i "%%F" -o "%%~nF.mp4"
(other command(s) featuring "%%F", "%%~nF", etc.)
)
This is tested on Windows 7,
but I’d be very surprised if it didn’t work on Windows 10.
.exe, I guess that you’re talking about Windows, but it’s good to say so explicitly. (2) Also, be more explicit about what you need. You show one command. What do you need to batch? Please do not respond in comments; [edit] your question to be clearer and more complete. – Scott - Слава Україні Oct 25 '17 at 01:47