for file in *; do myfile=`echo $file | sed -e 's/ //g'`; first=`echo $myfile | sed 's/^\(.*\)\.\(.*\)/\1/'|tr '[a-z]' '[A-Z]'`; ext=`echo $myfile | sed 's/^\(.*\)\.\(.*\)/\2/'|tr '[A-Z]' '[a-z]'`; mv "$file" `echo "$first.$ext"`; done
Monday, July 23, 2007
Shell script to re-name first part of filename to uppercase, and the extension to lowercase
For example ck100.Jpg -> CK100.jpg. Also removes spaces. Must be run in the directory the files are located in.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment