Skip to content

Instantly share code, notes, and snippets.

@vdugnist
Created April 1, 2018 08:02
Show Gist options
  • Save vdugnist/c4af395ea9ff1cf85495202e4bdadbc6 to your computer and use it in GitHub Desktop.
Save vdugnist/c4af395ea9ff1cf85495202e4bdadbc6 to your computer and use it in GitHub Desktop.
Compress video folder
#!/bin/bash
if [[ ! $1 ]]; then
echo "directory path is required"
exit 1
fi
dir_path=$1
# remove last '/' if needed
if [ "${$dir_path: -1}" == "/" ]; then
dir_path=${dir_path%?}
fi
mkdir $dir_path-compressed
for filename in $(ls $dir_path); do
original_file_path=$dir_path/$filename
result_file_path=$dir_path-compressed/$filename
if [ ! -e $result_file_path ]; then
ffmpeg -i $original_file_path $result_file_path
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment