Unix questions - script to rename files

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > August 2006 > script to rename files





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author script to rename files
A

2006-08-17, 1:19 pm

Hi -

I have 124 files each with the same first 8 letters/numbers (e6961s5i)
then numbered 001, 002 through 124 (for example e6961s5i001)

Currently all of these files do not have an extension and I would like
them to all have the extension .mr

Can anyone tell me how to write script that does this? All the files
are in the same directory.

Thanks
A

Chris F.A. Johnson

2006-08-17, 1:19 pm

On 2006-08-17, A wrote:
> Hi -
>
> I have 124 files each with the same first 8 letters/numbers (e6961s5i)
> then numbered 001, 002 through 124 (for example e6961s5i001)
>
> Currently all of these files do not have an extension and I would like
> them to all have the extension .mr
>
> Can anyone tell me how to write script that does this? All the files
> are in the same directory.


for file in e6961s5i*
do
mv "$file" "$file.mr"
done

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com