Created
July 15, 2012 17:12
-
-
Save raws/3117772 to your computer and use it in GitHub Desktop.
Bash helper script for recursively lowercasing file names
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
#!/bin/bash | |
# | |
# downcase PATH | |
# | |
# Recursively convert all file names contained in the given directory | |
# tree (but excluding the given directory itself) to lowercase. | |
# Existing files which are named identical to new, lowercased file | |
# names will be clobbered. | |
# | |
# Author: Ross Paffett <[email protected]> | |
# Inspiration: http://stackoverflow.com/a/152836 | |
if [ -n "$1" ]; then | |
find "$1" -depth -mindepth 1 \( -type d -or -type f \) -print0 | xargs -0n 1 bash -c \ | |
'src=$(dirname "$0")/$(basename "$0"); | |
dst=$(dirname "$0")/$(basename "$0" | tr "[A-Z]" "[a-z]"); | |
mv -fv "$src" "$dst"' | |
else | |
echo "usage: downcase PATH" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment