diff --git a/files/scripts/compress_video.sh b/files/scripts/compress_video.sh index 24f2d8b..4d14a04 100755 --- a/files/scripts/compress_video.sh +++ b/files/scripts/compress_video.sh @@ -48,7 +48,8 @@ function usage { -r : Recurse the entire directory structure, compressing all video files. -f : Force recompressing any files by deleting it if it already exists. -d : Delete the original video if the compressed version is smaller. - -A : Recursively Force and Delete. + -l : Clean the filename of dashes and underscores so dates line up. + -A : Recursively Force, Delete, and Clean. -m : Measure the time it takes to compress each video and do the loop. -V : Add verbosity, such as printing all the variable values. -x : Set the shell's x flag to display every action which is taken. @@ -59,7 +60,7 @@ function usage { ## Parameters ## -while getopts ":i:v:a:c:s:rfdAmVxh" opt; do +while getopts ":i:v:a:c:s:rfdlAmVxh" opt; do case $opt in i) input="$OPTARG" ;; @@ -77,7 +78,9 @@ while getopts ":i:v:a:c:s:rfdAmVxh" opt; do ;; d) delete="Y" ;; - A) search_command="find" && force="Y" && delete="Y" + l) clean="Y" + ;; + A) search_command="find" && force="Y" && delete="Y" #&& clean="Y" ;; m) time_command="`which time`" ;; @@ -212,21 +215,33 @@ $search_command "$input" | sort | while read file; do continue fi + # TBD / TODO: Test this functionality! + new_video_clean="${newfile}" + new_video_clean="${new_video_clean//_/}" + new_video_clean="${new_video_clean//-/}" + new_video_clean="${new_video_clean// /}" + # More exception checks based on the new file. - if [[ -e "$newfile" ]]; then + if [[ -e "$newfile" || -e "$new_video_clean" ]]; then if [[ "$force" == "Y" ]]; then echo "FORCE: Removing '$newfile'." if [[ -d ~/TRASH ]]; then - mv -v "$newfile" ~/TRASH/ + mv -v "$newfile" "$new_video_clean" ~/TRASH/ 2>/dev/null else - rm -v "$newfile" + rm -v "$newfile" "$new_video_clean" 2>/dev/null fi else - echo "SKIP: Already has a compressed version ($newfile)." + echo "SKIP: Already has a compressed version." + ls -sh "$newfile" "$new_video_clean" 2>/dev/null continue fi fi + # Whether or not to use the cleaned version or the normal version. + if [[ -n $clean ]]; then + newfile="$new_video_clean" + fi + # Convert the file. echo "Converting to '$newfile'." echo "*** `date` ***"