Solved

Rename large number of files

Posted on 2006-06-23
3
259 Views
Last Modified: 2010-04-21
I need some help with a script to run on Solaris 10.  
I have approximetly 1000 files that are named myIMG.bmp.1 all the way to myIMG.bmp.1006.

I need to rename them all.

What I would like is someone to be able to rename for example myIMG.bmp.1 to 1.bmp.  

IMPORTANT
Also there are other files in the directory I don't want to rename any that do not end in a number.  
0
Comment
Question by:devildog1775
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
ID: 16973036

This will generate a script that will do it for you:

 ls myIMG.bmp.*|awk '{print "mv " $1 " " $1}'|sed 's/myIMG.bmp.//2;s/$/.bmp/g'


And something similar could also be run through find.



Good Luck,
Kent
0
 

Author Comment

by:devildog1775
ID: 16973133
and even one line... :-) tks
0
 
LVL 45

Expert Comment

by:Kdo
ID: 16975174
Hi devildog1775,
> and even one line... :-) tks

Why use two, when one will do?   :~}


Kent
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
aix tls version 6 305
Skill Development 15 174
OpenLDAP Proxy to Active Directy 6 275
Doing a DR (Disaster Recovery) Test on Red Hat Linux Servers. 2 113
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now