Created
August 20, 2024 16:08
-
-
Save huevos-y-bacon/e880b2b31d18bcf876b161c74ebe691d to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Rename all directories (not files) in the current directory to lowercase, Replace underscores and spaces with hyphens | |
# Find all directories in the current directory and rename them | |
find . -maxdepth 1 -mindepth 1 -type d | while read -r d; do | |
# strip leading ./ and trailing / | |
d=$(basename "$d") | |
d2=$(echo "$d" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr '_' '-') | |
if [ "$d" != "$d2" ]; then | |
echo "Renaming $d to $d2" | |
mv "$d" "$d2" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment