filename-changing application

Subject: filename-changing application
From: Jean Jordaan <Jean -at- mosaicsoftware -dot- com>
To: "'Susan Kirsch'" <susan -at- virtualcyber -dot- com>
Date: Fri, 28 Apr 2000 10:09:33 +0200

Hi Susan

> Somehow an associate has gotten herself into a situation
> where she needs to change the filename on a humongous number
> of files.

If you have access to a Unix-ish commandline environment (which
includes things like the Cygnus system for Windows [1]), you
can use this shell script:

-----------cut-----------
#!/bin/sh
# rename : rename multiple files

if [ $# -lt 3 ] ; then
echo
echo "Usage: rename \"pattern\" \"replacement\" files..."
echo
exit 1
fi

OLD=$1 ; NEW=$2 ; shift ; shift

for file in $*
do
new=`echo ${file} | sed s/${OLD}/${NEW}/g`
echo "Renaming ${file} to $new"
mv ${file} $new
done
-----------cut-----------

This way, you can use regular expressions for the old and new names ..

--
jean -at- mosaicsoftware -dot- com . ... .... ///\\oo//\\\
Technical Writer




Previous by Author: RE: ESL and translation issues
Next by Author: screen captures in UNIX?
Previous by Thread: RE: filename-changing application
Next by Thread: RE: Trying to flee the country (really long)


What this post helpful? Share it with friends and colleagues:


Sponsored Ads