Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I rename Multiple Files?

Renaming Files

How do I rename Multiple Files?

by  pcunix  Posted    (Edited  )
From http://pcunix.com/SCOFAQ/scotec1.html#rename :
You can't do it as you would in DOS, but you can do it.

First, the "mv" command is what renames a file- you are "moving" it to a new name.

To rename with wildcards, you need to write a simple shell script. This can be done with any shell, but shells like ksh make it easier. For example, here's a couple of scripts to
rename a bunch of uppercase file names to lowercase:

# [A-Z]* matches upper case names
for i in [A-Z]*
do
j=`echo $i | tr '[A-Z]' '[a-z]'`
mv $i $j
done


Note the backtics ("`") carefully.

With ksh this becomes easier:

#!/bin/ksh
typeset -l j
for i in [A-Z]*
do
j=$i
mv $i $j
done
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top