nix, shell, perl, php, mysql and mac os x tips and tricks

Tuesday, April 4, 2006

Shell script to make all files in directory lowercase

#!/bin/bash
for i in $(ls); do
    oldname="$i"
    newname=$(echo "$oldname" | tr 'A-Z' 'a-z')
    if [ "$oldname" != "$newname" ]
        then
            mv -i "$oldname" "$newname"
        fi
done

No comments:

Post a Comment