Working script, Would like someone to look at for me

First off I have to say, it is because of this forum and countless Google searches I have this script working at all. So thank you for that.

I have created a web based open source project and I am trying to automate some of the tasks when I am releasing a new version. I do most of my development on my Windows box and have a test site running on a local Linux test server.

I have created a script and if I can get a few optimization pointers on it I would appreciate it very much.

This script does exactly what I want it to and I want to know, is there a better way?

#!/bin/bash

CONVERT_FROM=ISO-8859-1
CONVERT_TO=UTF-8

# move into our working directory
cd /var/www/localhost/htdocs/dist/

# remove execute bit
find . -type f -name "*.*" -exec chmod 664 {} \;
echo "Files have been modified to remove the execute bit"

# if line endings in our file are windows CR change to unix
find . -type f -name "*.*" -exec dos2unix -q -o {} \;
echo "Dos 2 Unix new line conversion has completed"

# delete any previous utf-8 files so we can write new ones
find . -type f \( -iname "*utf8*" \) -exec rm -f {} \;
echo "Old UTF-8 files have been deleted"

# get all files in our current working directory and make sure they are UTF-8 charset
find . -type f \( ! -iname "*.ttf" ! -iname "*.gif" ! -iname "*.jpg" ! -iname "*.jpeg" ! -iname "*.png" \) -exec iconv -f $CONVERT_FROM -t $CONVERT_TO -s -o {}.utf8 {} \;
echo "New UTF-8 files have been created"

# delete unconverted files so we can move the new files back later
find . -type f \( ! -iname "*.utf8" ! -iname "*.ttf" ! -iname "*.gif" ! -iname "*.jpg" ! -iname "*.jpeg" ! -iname "*.png" \) -exec rm {} \;
echo "Removal of original unconverted files is complete"

# rename all files converted to utf-8 with utf8 extension
mmv -m ";*.utf8" "#1#2"
# deal with .htaccess
mmv -m ";.*.utf8" "#1.#2"
echo "Dist Prep has completed"

This is the first step in the rest of my automation scheme. After this runs then I will work on some automated diffs and tar functions.

Thanks for any advice.
Best Regards,
Brandon

did you mean 'mv' instead of 'mmv'

don't have to use that many find commands. you can use it just one time, then pipe whatever files it find to while read loop

find . -type f -name "*.*" | while read FILE
do
 chmod 664 $FILE
 dos2unix $FILE $FILE
 case $FILE in
    *utf8* )) rm -f $FILE    
 esac
 #continue

done

ghostdog74, thanks for that it worked perfectly after I removed the extra ). That is much more elegant and succinct then what I had.

find . -type f -name "*.*" | while read FILE
do
  chmod 664 $FILE
  dos2unix $FILE $FILE
  case $FILE in
  *utf8* ) rm -f $FILE    
 esac
#continue

done

matrixmadhan, Yes I was referring to mmv not mv. mmv was something I stumbled on while looking to do recursive file renames because I was having issues getting mv, cp or rename to work.

Thanks for the quick responses.
Best Regards,
Brandon

mmv?

I have not heard about, is it for multiple-mv's ? Which distribution is it?

I am running it on Gentoo and just emerged it

emerge mmv

According to the link below you can get it from any other repo I have had a hard time finding just a source package for it though.

Linux Blog mmv � move multiple files by wildcard patterns

Best Regards,
Brandon