[Gllug] error in bash script to rename files in a directory

Liam Delahunty ldelahunty at britstream.com
Fri Dec 27 23:44:37 UTC 2002


Paul Cupis wrote:
On Friday 27 Dec 2002 22:34, Liam Delahunty wrote:
>> for i in `ls *.php3`; do mv $i `echo $i|tr 'php3' 'php'`; done
>> I now have *.phpp

>In short, I think you must have some error with your echo/tr section.

Yep! It turns out that tr isn't an expression in the normal manner so, my
command said, (I think) translate p to p, translate h to h, translate p to
p, translate 3 to p
as I didn't have any numerals in the file names it only affected the
extension.

I repaired my error with "rename" (I thought we didn't have rename which was
why I bothered with the mv tr stuff)

rename phpp php *.phpp

Then in vi I did the following for each of the files to sort out the
internal links.
 :1,$s/php3/php/g

However, I'm sorry, but for me that's still not as quick or easy as a DOS
rename and
then an extended search and replace in Home Site, but I might get the hang
of this Linux lark yet... ;)

Many thanks for your help/assistance/support.

kind regards,
Liam


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list