How can I batch convert files in a directory, using a custom preset and preserving the structure of any sub-directories?

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
SpitefulMonkey
Posts: 2
Joined: Sat Jun 24, 2017 2:25 pm

How can I batch convert files in a directory, using a custom preset and preserving the structure of any sub-directories?

Post by SpitefulMonkey »

I'm using v1.0.7 and have HandbrakeCLI installed on MacOS Sierra. I would like to batch convert videos in a source directory whilst recursively preserving the names and structure of any sub-directories those videos might be in. I would also like to use my own custom preset. I understand that Handbrake is unable to do this via the GUI, but can it be done via the CLI? I attempted to modify SurlyJake's script for batch conversion, but just made a mess of it :/
mduell
Veteran User
Posts: 8187
Joined: Sat Apr 21, 2007 8:54 pm

Re: How can I batch convert files in a directory, using a custom preset and preserving the structure of any sub-director

Post by mduell »

You could do this with a short shell script wrapping the CLI (i.e. calling the CLI for each video it finds).
fastwestie
New User
Posts: 1
Joined: Sat Oct 07, 2017 2:35 pm

Re: How can I batch convert files in a directory, using a custom preset and preserving the structure of any sub-director

Post by fastwestie »

Are there any sample scripts for this?
Segfault
Posts: 37
Joined: Sat Jun 17, 2017 3:08 am

Re: How can I batch convert files in a directory, using a custom preset and preserving the structure of any sub-director

Post by Segfault »

Today morning I needed to convert about 200 files in a directory, below is how I did it. I hope it gets you started.

Code: Select all

for i in *.mkv ;
do HandBrakeCLI -i "$i" -g --nlmeans=light --nlmeans-tune film -f av_mkv -e x265 -q 22 --vfr -E opus -B 64 -o "new/${i%mkv}mkv" ;
done
SpitefulMonkey
Posts: 2
Joined: Sat Jun 24, 2017 2:25 pm

Re: How can I batch convert files in a directory, using a custom preset and preserving the structure of any sub-director

Post by SpitefulMonkey »

Segfault wrote: Sun Oct 08, 2017 7:19 pm Today morning I needed to convert about 200 files in a directory, below is how I did it. I hope it gets you started.

Code: Select all

for i in *.mkv ;
do HandBrakeCLI -i "$i" -g --nlmeans=light --nlmeans-tune film -f av_mkv -e x265 -q 22 --vfr -E opus -B 64 -o "new/${i%mkv}mkv" ;
done
Presumably that's for 200 files in one directory, isn't it? Not 200 files in 200 (or whatever) sub-directories?
Post Reply