Help to replace a blank space with a backslash and blankspace in a variable in Run Shell Command with Automator
I don't have Compressor.app to test with, but this should work:
fileargs=()
for d in "$@"
do
[ -f "$d" ] || continue
filename=$(basename "$d")
fname="$(dirname "$d")"/"${filename%.*}"
fileargs+=(-jobpath "$d" -settingpath /Applications/Compressor.app/Contents/Resources/Settings/ProRes/proResHQName.setting -locationpath "$fname".mov)
done
/Applications/Compressor.app/Contents/MacOS/Compressor -batchname MyFirstBatch "${fileargs[@]}"
EDIT: If you want to restrict it to just specific file extensions (.mov, .mp4, and .mxf), you can use this instead:
fileargs=()
for d in "$@"
do
[[ "$d" =~ [.](mov|mp4|mxf)$ ]] || continue
[ -f "$d" ] || continue
fileargs+=(-jobpath "$d" -settingpath /Applications/Compressor.app/Contents/Resources/Settings/ProRes/proResHQName.setting -locationpath "${d%.*}".mov)
done
/Applications/Compressor.app/Contents/MacOS/Compressor -batchname MyFirstBatch "${fileargs[@]}"
Note that with this restriction, the filename is guaranteed to have an extension, so the ${d%.*}.mov
trick that @user3439894 suggested is safe to use. Also, is it ok to use the the same -jobpath
and -locationpath
names? (This'll happen when both the input and output files are .mov.)