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