Skip to content

Instantly share code, notes, and snippets.

@dneprDroid
Last active August 3, 2019 10:01
Show Gist options
  • Select an option

  • Save dneprDroid/7ba47c6e2bf00612e7421d8a18891b21 to your computer and use it in GitHub Desktop.

Select an option

Save dneprDroid/7ba47c6e2bf00612e7421d8a18891b21 to your computer and use it in GitHub Desktop.
dir_mov_to_mp4
#!/bin/bash
function convert_in_dir() {
dir_path=$1
extension=$2
for filename in $dir_path/*.$extension; do
echo $filename
file_date=`date -r $filename "+%Y-%m-%d %H-%M"`
new_filename="${filename} ${file_date}.mp4"
if [ ! -f "$new_filename" ]; then
echo "-> $new_filename"
ffmpeg -i "${filename}" -qscale 0 "${new_filename}" > /dev/null 2>&1
else
echo " Conversion of ${filename} already exists: ${new_filename}"
fi
done
}
echo "Usage:"
echo " $sh dir_mov_to_mp4 dir/path/to/mov/files"
echo "------------------------------------------"
dir_path=$1
echo "Directory: ${dir_path}"
convert_in_dir $dir_path MOV
convert_in_dir $dir_path mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment