Re: Renaming/Moving a Group of Filenames

From: Coyle, Jack (Jack.Coyle@REXHEALTH.COM)
Date: Fri Jan 30 2004 - 11:17:00 EST


Mark,

One way this could be done is as follows (assuming you are in directory of
interest):

ls -1 test* | while read a b ; do
   tmp=$(echo $a | sed s/.txt//)
   mv $a $tmp".xyz"
done

BTW, that is a numeric 1 as an option to the ls command, not an alphabetic
l.

Regards,
Jack Coyle
Rex Healthcare
(919) 784-3792
jack.coyle@rexhealth.com

> ----------
> From: Mark Monroe[SMTP:mark.monroe@FORMSANDSUPPLY.COM]
> Reply To: IBM AIX Discussion List
> Sent: Friday, January 30, 2004 11:00 AM
> To: aix-l@Princeton.EDU
> Subject: Renaming/Moving a Group of Filenames
>
> I need help with something that I think is very simple. My mind is over
> thinking the process and I cant seem to think of any easy way to
> accomplish something.
>
> I have a several files in a directory such as this:
>
> test001.txt
> test002.txt
> test003.txt
> test004.txt
>
> I want to rename the extension on the whole list to be something different
> like this:
>
> test001.xyz
> test002.xyz
> test003.xyz
> test004.xyz
>
> Is there an easy way with the cp or mv command to take test*.txt and
> create the new files as test*.xyz?
>
> Any thoughts or ideas are appreciated,
>
> Mark
>



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:17:33 EDT