dotfiles

My dotfiles for Arch Linux
git clone git://git.janispagel.de/dotfiles.git
Log | Files | Refs | README

lowercase.sh (624B)


      1 #!/bin/bash
      2 
      3 
      4 find . -depth -mindepth 1 -exec bash -c '
      5   for file do
      6     # adapt the awk command if you wish to rename to something other than lowercase
      7     newname=$(dirname "$file")/$(basename "$file" | awk "{print tolower(\$0)}")
      8     if [ "$file" != "$newname" ] ; then
      9         # the extra step with the temp filename is for case-insensitive filesystems
     10         if [ ! -e "$newname" ] && [ ! -e "$newname.lcrnm.tmp" ] ; then
     11            mv -T "$file" "$newname.lcrnm.tmp" && mv -T "$newname.lcrnm.tmp" "$newname" 
     12         else
     13            echo "ERROR: Name already exists: $newname"
     14         fi
     15     fi    
     16   done
     17 ' sh {} +