Last active
June 18, 2020 13:47
-
-
Save rfht/f9b83d5e412b77791c053aaf265e85f6 to your computer and use it in GitHub Desktop.
turn all filenames in $PWD to lowercase recursively
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
#!/bin/sh | |
if [ -z "$1" ] ; then | |
WD=. | |
else | |
WD="$1" | |
fi | |
lower= | |
lowercase() | |
{ | |
lower="$(echo `basename "$1"` | tr '[A-Z]' '[a-z]')" | |
mv -v "`dirname "$1"`/`basename "$1"`" "`dirname "$1"`/$lower" | |
if [ $? -gt 0 ] ; then | |
echo "error lowercasing $1" | |
exit | |
fi | |
} | |
# grep for directory separator '/' to not include '.' | |
for f in `find -d "$WD" | grep '/'`; do | |
lowercase "$f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment