[SunHELP] Just rename file

Will Mc Donald wmcdonald at ntlworld.com
Wed Oct 30 02:22:07 CST 2002


There's probably an easier, more efficient way of doing this but it's early in
the morning and the best I can come up with is something like...

for oldfile in *.xxx-*
do
    newfile=`echo $oldfile | sed 's/xxx/yyy/'`
    echo $newfile
    # "mv $oldfile $newfile"
done

If you replace the "echo $newfile" with "mv $oldfile $newfile" that'll
mv/rename the files for you.

Googling http://makeashorterlink.com/?S6E252842 turns up pretty much the same
result...

http://www.fnal.gov/docs/UNIX/unix_at_fermilab/htmldoc/rev1997/uatf-144.html

Will.

----- Original Message -----
From: "Sangbutsarakum, Patai" <patais at reach.com>
To: <sunhelp at sunhelp.org>
Sent: Wednesday, October 30, 2002 6:45 AM
Subject: [SunHELP] Just rename file


> If I want to rename the files at the same time, same pattern
> Ex.
> I have these file.
> file.xxx-day.png
> file2.xxx-week.png
> file3.xxx-month.png
> file4.xxx-year.png
>
> want to change it to be
>
> file.yyy-day.png
> file2.yyy-week.png
> file3.yyy-month.png
> file4.yyy-year.png
>
> Is that anyway to rename these files at the same time,
> to save typing from 'mv' for each file.
> Because now I have a hundreds of this kind of  files.
>
> Thanks,
> pat.
> _______________________________________________
> SunHELP maillist  -  SunHELP at sunhelp.org
> http://www.sunhelp.org/mailman/listinfo/sunhelp



More information about the SunHELP mailing list