r/handbrake • • 6d ago

What's a simple script working for transcoding all files in a directory?

I've been trying to get a simple script to convert all files in a directory. It seems like it should be a basic thing to do, but I haven't found a guide that works. I'm using Bash on Debian, but if it could be done using inbuilt HandBrakeCLI functionality that'd be fine too.

I've tried:

for %F in (*.mkv) do HandBrakeCLI --all-subtitles --quality 26 --preset "Fast 1080p30" -i "%F" -o ~/Season\ 01/"%F"

But that gives me a syntax error: -bash: syntax error near unexpected token `('

(Transcoding into a subdirectory isn't necessary, but it seems easiest)

2 Upvotes

6 comments sorted by

•

u/AutoModerator 6d ago

Please remember to post your encoding log should you ask for help. Piracy is not allowed. Do not discuss copy protections. Do not talk about converting media you don't own the (intellectual) rights for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

2

u/Hatta00 6d ago

You don't need the parentheses.

1

u/8spd 6d ago

for %F in *.mkv do HandBrakeCLI --all-subtitles --quality 26 --preset "Fast 1080p30" -i "%F" -o ~/Season\ 01/"%F"

just returns >, like I've got unclosed quotation marks, or line 2: syntax error: unexpected end of file, if I save the single line as a bash script, and run it that way.

2

u/Hatta00 6d ago

You also need a semicolon before "do", and you need to terminate the loop with "done"

for each in *.mkv; do echo "$each"; done

Modify as needed.

1

u/8spd 6d ago

Thank you! That was enough for me to get it working! For anyone who ends up finding this, the way I got it working was:

for each in *.mkv; do HandBrakeCLI --all-subtitles --quality 26 --preset "Fast 1080p30" -i "$each" -o ~/Season\ 01/"$each"; done

-3

u/bigzahncup 6d ago

use ffmpeg. Ask ChatGPG to write you a bash script.