Using the GUI tool ALWAYS crashes for me so I've come up with a command to convert my files to my needs. It takes a preset that I created in the GUI and converts the file.
I have many videos that I need converted and would like to know if it's possible to batch convert using some sort of script that reads all of the .MOV videos in a folder and converts them to .mp4 using the command I have provided.
I'm running Windows 10.
Here's my command, I'm using nightly builds:
HandBrakeCLI.exe --preset-import-file "preset-name.json" -Z "preset-name" -i video.MOV -o video.mp4
Edited with a clearer request.
Best Answer
OK, I guess you have a bunch of files like
in a directory (a.k.a. folder), and you want to do
for all the
*.mov
files. This is fairly straightforward:The
for %F in (*.mov)
runs a loop in which%F
takes on every applicable*.mov
name. Then the command following thedo
is executed for each file, with%F
obviously being replaced by the.mov
file name. (Note: theF
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:
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
^
: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%%
:This is tested on Windows 7, but I’d be very surprised if it didn’t work on Windows 10.