I have this little bash script I use to transcode mkv files using handbrake.
#!/bin/bash
sourcedir="/media/raid10/video/to_be_encoded_series"
destdir="/media/raid10/video/series"
cd "$sourcedir"
for i in *.mkv; do
HandBrakeCLI -i "$i" -o "$destdir/${i%.*}.mkv" -e x264 -q 20.0 -E copy -B auto -6 auto -R Auto -D 0.0 -f mkv --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50
mv "$i" /media/raid1/orig_series_mkv/"$i"
done
This is great for transcoding a batch of films all contained in the source directory, but I can't make it run recursively for files grouped into sub directories. I would also like to preserve the directory structure in the destination directory.
Thanks
Use find to search the subdirs and feed its output to a loop...
find <path_to_dir> -type f -name "*.mkv" | while read i
do
<HandBrakeCLI command and args.>
<mv command and args.>
done
Thanks,
Will this also preserve the directory structure in the destiation directory?
ie
/source/TVseries/original_file.mkv
to
/destination/TVseries/transcoded_file.mkv
Yes it will...as long as you use the move comand in your first post.
No luck I'm afraid, Handbrake runs but doesn't transcode anything and then there is an error with the mv command. I have commented out the cd and mv command to just leave the handbrake args but still no luck, here is my script:
#!/bin/bash
sourcedir="/media/raid10/video/to_be_encoded_series"
destdir="/media/raid10/video/series"
#cd "$sourcedir"
#for i in *.mkv; do
find "$sourcedir" -type f -name "*.mkv" | while read i
do
HandBrakeCLI -i "$i" -o "$destdir/${i%.*}.mkv" -e x264 -q 20.0 -E copy -B auto -6 auto -R Auto -D 0.0 -f mkv --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50
#mv "$i" /media/raid1/orig_series_mkv/"$i"
done
Thanks