aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorclyhtsuriva <aimeric@adjutor.xyz>2023-06-27 20:40:13 +0200
committerclyhtsuriva <aimeric@adjutor.xyz>2023-06-27 20:40:13 +0200
commitdab214b31a4aeb9f16806c6215da334c23634bc8 (patch)
treed4da86900b1d370f7a09dcffa025f4b240894ed5 /bin
parent5a3f7ffdc70538b87a78c367b6fba743d11e5a7d (diff)
Commenting out echo used for debug
Diffstat (limited to 'bin')
-rwxr-xr-xbin/convert-filenames.sh25
1 files changed, 13 insertions, 12 deletions
diff --git a/bin/convert-filenames.sh b/bin/convert-filenames.sh
index 9ccba13..f880eeb 100755
--- a/bin/convert-filenames.sh
+++ b/bin/convert-filenames.sh
@@ -15,50 +15,51 @@ for file in "$@"; do
exit 1
fi
- echo "$file"
+# echo "$file"
# Get the lowercase version of the file name
new_name=$(basename "$file" | tr '[:upper:]' '[:lower:]')
- echo "$new_name"
+# echo "$new_name"
-# Replace parentheses, brackets, and square brackets with dashes
+ # Replace parentheses, brackets, and square brackets with dashes
new_name=${new_name//[()]/-}
new_name=${new_name//\[/-}
new_name=${new_name//\]/-}
- echo "$new_name"
+# echo "$new_name"
# Remove special characters that are not '_', '-', '.' and spaces.
new_name=${new_name//[^a-zA-Z0-9_. -]/}
- echo "$new_name"
+# echo "$new_name"
# Replace spaces with '_'
new_name=${new_name// / }
new_name=${new_name// /_}
- echo "$new_name"
+# echo "$new_name"
# Replace consecutive occurrences of '_-_', '_-', '-_' and '-_-' by '-'.
new_name=${new_name//_\-_/-}
new_name=${new_name//_\-/-}
new_name=${new_name//-\_/-}
new_name=${new_name//-\-_/-}
- echo "$new_name"
+# echo "$new_name"
# Replace consecutive occurrences of '-.' by '.'.
new_name=${new_name//\-\./.}
- echo "$new_name"
+# echo "$new_name"
# Replace consecutive occurrences of '--' with a single '-'.
new_name=${new_name//--/-}
- echo "$new_name"
+# echo "$new_name"
# Replace multiple underscores with single '_'.
new_name=${new_name//__/_}
- echo "$new_name"
+# echo "$new_name"
# Remove leading special characters
new_name=${new_name##[![:alnum:]]}
- echo "$new_name"
+# echo "$new_name"
# Rename the file
- mv "$file" "$(dirname "$file")/$new_name"
+ mv "$file" "$(dirname "$file")/$new_name" 2> /dev/null
+ echo "$(dirname "$file")/$new_name"
done