понедельник, 5 июня 2006 г.

Files and Folders to lower case


#!/bin/bash
if [ "$1" == "" ]
then
echo -e "Usage: tolowcase 'path'\nFor exapmle:
tolowcase \"$HOME/.wine/drive_c/Program Files/\"
tolowcase \"$HOME/.wine/drive_c/Program Files\"
tolowcase $HOME/.wine/drive_c/Program\ Files"
exit
fi

list=`find "$1" | sort -r | sed "s/\ /\[:space:\]/g"`

for name in $list
do
name=`echo $name | sed "s/\[:space:\]/\ /g"`
path=`echo $name | sed 's/[^\/]*$//g'` # pathname
nameorig=`echo $name | sed 's/.*\///g'` # filename
namechng=`echo $nameorig | tr [:upper:] [:lower:]`
if [ "$nameorig" != "$namechng" ]
then mv "$path$nameorig" "$path$namechng"; echo "$path$nameorig -> $namechng"
fi
done

Комментариев нет: