UNTESTED: Add cleaning of the video filename.

This commit is contained in:
Hyperling 2025-04-03 14:50:01 -07:00
parent e308beec07
commit 3bca080de1

View File

@ -48,7 +48,8 @@ function usage {
-r : Recurse the entire directory structure, compressing all video files. -r : Recurse the entire directory structure, compressing all video files.
-f : Force recompressing any files by deleting it if it already exists. -f : Force recompressing any files by deleting it if it already exists.
-d : Delete the original video if the compressed version is smaller. -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. -m : Measure the time it takes to compress each video and do the loop.
-V : Add verbosity, such as printing all the variable values. -V : Add verbosity, such as printing all the variable values.
-x : Set the shell's x flag to display every action which is taken. -x : Set the shell's x flag to display every action which is taken.
@ -59,7 +60,7 @@ function usage {
## Parameters ## ## Parameters ##
while getopts ":i:v:a:c:s:rfdAmVxh" opt; do while getopts ":i:v:a:c:s:rfdlAmVxh" opt; do
case $opt in case $opt in
i) input="$OPTARG" i) input="$OPTARG"
;; ;;
@ -77,7 +78,9 @@ while getopts ":i:v:a:c:s:rfdAmVxh" opt; do
;; ;;
d) delete="Y" 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`" m) time_command="`which time`"
;; ;;
@ -212,21 +215,33 @@ $search_command "$input" | sort | while read file; do
continue continue
fi 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. # More exception checks based on the new file.
if [[ -e "$newfile" ]]; then if [[ -e "$newfile" || -e "$new_video_clean" ]]; then
if [[ "$force" == "Y" ]]; then if [[ "$force" == "Y" ]]; then
echo "FORCE: Removing '$newfile'." echo "FORCE: Removing '$newfile'."
if [[ -d ~/TRASH ]]; then if [[ -d ~/TRASH ]]; then
mv -v "$newfile" ~/TRASH/ mv -v "$newfile" "$new_video_clean" ~/TRASH/ 2>/dev/null
else else
rm -v "$newfile" rm -v "$newfile" "$new_video_clean" 2>/dev/null
fi fi
else 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 continue
fi fi
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. # Convert the file.
echo "Converting to '$newfile'." echo "Converting to '$newfile'."
echo "*** `date` ***" echo "*** `date` ***"