[Leaplist] help with renaming script

Ray Brunkow ray at brunkow.ws
Thu Dec 24 17:54:59 EST 2009


I do not know how to script.  I have a simple script that I got some 
help about a year back or so to replace spaces with _ but now i am in 
need of replacing entire file names with sequential numbers in order to 
get them to function properly with Dreamweaver to make a photo album of 
roughly 200M worth of pictures.  I really do not want to go and manually 
rename every single file.  that would just take way to long.

====================

#!/bin/bash
#
#       remove spaces in names of files and replace them with '_'
#
         function basic {
         for i in *
         do
                 if [ -d "$i" ]
                 then
                         cd "$i"
                         remove_space2.sh #name of this script from LQ 
member dive.  Must be in PATH or full path to script must be given.
                         cd ..
                 fi
                 tempa=$(echo "$i" | sed 's/ /_/g' | sed 's/_-_/-/g' | 
sed -e 's/\ -\ /-/g' | sed 's/__/_/g' \
                 | sed "s#'##g" | sed "s#;##g" | sed "s#,##g")
                 [[ "$i" != "$tempa" ]] && mv -v "$i" "$tempa"
         done
         }

         function cmd {
         for i in "$@"
         do
                 tempa=$(echo "$i" | sed 's/ /_/g' | sed 's/_-_/-/g' | 
sed -e 's/\ -\ /-/g' | sed 's/__/_/g' \
                 | sed "s#'##g" | sed "s#;##g" | sed "s#,##g")
                 [[ "$i" != "$tempa" ]] && mv -v "$i" "$tempa"
                 [[ ! -d "$tempa" ]] && break
                 cd "$tempa"
                 remove_space2.sh #name of this script from LQ member 
dive.  Must be in PATH or full path to script must be given.
                 cd ..
         done
         }

         [[ "$@" != "" ]] && cmd "$@"
         [[ "$@" == "" ]] && basic

==============

is there a simple way to modify that script to do what i need?  no i did 
not code that.   the good folks over at LinuxQuestions.org helped with 
that one.

-- 
Raymond L. Brunkow
5th Degree Black Belt
Certified Instructor
Choong Sil Kwan TaekwonDo Federation


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Leaplist mailing list