I got to this solution yesterday with help from here (it's finding a list of directories to process with HandBrakeCLI, and putting the results in a hard-coded directory):
#!/bin/bash
source_dir=/Volumes/VolumeName
dest_dir=/Volumes/OtherName
export dest_dir # export allows use by subprocesses!
find "$source_dir" -type d -name "VIDEO_TS" -exec bash -c '
for dir; do
name=${dir%/VIDEO_TS}
name=${name##*/}
./HandBrakeCLI -i "$dir" -o "$dest_dir/$name.m4v"
done
' _ {} +
The shell script works fine, but if I try to stop it by killing the main process:
kill -9 <pid>
it seems to work but then comes back to life and calls HandBrakeCLI with the next file in the list generated by find.
Is there a way of reliably stopping the whole thing? I'm assuming that somehow the future calls to the CLI are being queued/cached, but could someone explain what's happening please?