Created
October 7, 2018 10:11
-
-
Save gibatronic/364c156e0e346783c1800ba9a3863769 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Convert any webm video file inside the Downloads folder to mp4 | |
# | |
# Usage: | |
# ./webm2mp4 | |
main() { | |
local videos=$(find ~/Downloads -name '*.webm') | |
if [ -z "$videos" ]; then | |
return | |
fi | |
while read path_webm; do | |
local path_mp4=${path_webm/%.webm/.mp4} | |
echo "$path_webm" "$path_mp4" | |
ffmpeg -i "$path_webm" "$path_mp4" | |
local exit_code=$? | |
if [ "$exit_code" = '0' ]; then | |
echo -en "\033[32m✓\033[0m" | |
rm "$path_webm" &> /dev/null | |
else | |
echo -en "\033[31m✖\033[0m" | |
fi | |
local file_mp4=$(basename "$path_mp4") | |
echo " $file_mp4" | |
done <<< "${videos[@]}" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment