[buug] Unix script for replacing character in file or folder name?

Robert Helmer robert at roberthelmer.com
Wed May 25 18:46:22 PDT 2005


-----8<-----

#!/bin/sh

REPLACE_CHAR=":"

for FILE in `find ./ -type f`
do
  echo $FILE | grep $REPLACE_CHAR > /dev/null
  if [ "$?" == "0" ]
  then
    mv $FILE `echo $FILE | sed s/:/-/g`
  fi
done

----->8-----



On Wed, May 25, 2005 at 08:33:53PM -0500, Gary Mielke wrote:
> I was wondering if anybody has a unix shell script that would replace a
> specific character in a file or folder. I would like the script to look into
> one directory and search all the sub folders and files and if it finds a ":"
> colon character in any of the names that it would replace it with a "_"
> underscore. Has anybody worked with a similar script that they would be
> willing to share?
> 
> Thanks for any help or suggestions.
> 
> Gary 
> 
> _______________________________________________
> Buug mailing list
> Buug at weak.org
> http://www.weak.org/mailman/listinfo/buug
> 



More information about the buug mailing list