Created
April 9, 2015 15:12
-
-
Save wesleybliss/dc9813e386e04e3c85dc to your computer and use it in GitHub Desktop.
Lowercase the names of all files in a directory (defaults to current directory).
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/bash | |
echo | |
path="." | |
counter=0 | |
remainder=0 | |
if [ ! -z "$1" ]; then | |
path="$1" | |
fi | |
echo "Lowercase File Names" | |
echo " > Getting file list" | |
# Get a list of files | |
files=`ls -1 $path` | |
# Get a file count | |
fc=`ls -1 $path | wc -l` | |
remainder=$fc | |
echo " > Renaming $fc files" | |
for f in $files; do | |
# Keep track of our iteration so long operations | |
# don't seem like they're hung/frozen | |
((counter++)) | |
((remainder--)) | |
if [ $((counter%2)) -eq 0 ]; then | |
echo " - $remainder remaining" | |
fi | |
# Get the lowercased name of the file | |
fl=`echo "$f" | awk '{print tolower($f)}'` | |
# Rename the file | |
mv "$f" "$fl" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment