![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| rename multiple files | antointoronto | Shell Programming and Scripting | 13 | 03-20-2008 10:16 AM |
| how to rename multiple files with a single command | tayyabq8 | Shell Programming and Scripting | 5 | 03-18-2008 04:04 PM |
| How to rename multiple files with a common suffix | er_ashu | UNIX for Dummies Questions & Answers | 1 | 09-28-2007 10:52 AM |
| Rename part of multiple files | sajjad02 | Shell Programming and Scripting | 4 | 02-22-2005 01:30 PM |
| Rename Multiple Files | molonede | UNIX for Dummies Questions & Answers | 1 | 11-14-2000 12:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello,
I want to rename multiple files at a time and I don't know how to do it. I have various ".mp3" files, like "band name - music name.mp3" and I want to remove the "band name" from all files. Anybody knows how to do it using shell script or sed or even perl? Thanks |
|
|||||
|
If you do a search for rename and files, you will come up with the following and more which should take care of your problem:
Rename files |
|
||||
|
Hello,
Thanks for your help but my problem it's a quite different for that answers. I don't want to rename the extensions of my files. I want to change the name of my files like this: "first name - second name.mp3" to "second name.mp3" Thanks |
|
|||||
|
But did you bother to do the search yourself? If so, you would have found the rest of what you needed.
more renamed files Part of the learning process is to do - not just have it done for you. This will give you almost what you are looking for....the PROD to TEST will help but YOU still have to think. It's the only way to learn. |
|
||||
|
I executed the script:
for file in *.mp3 do newfile=`echo $file | sed 's/black\ sabbath\ //g'` file=`echo $file | sed 's/ /_/g'` mv $file $newfile done and the result was: mv: cannot access black_sabbath_music1.mp3 mv: cannot access black_sabbath_music2.mp3 mv: cannot access black_sabbath_music3.mp3 mv: cannot access black_sabbath_music4.mp3 my files are: black sabbath music1.mp3 black sabbath music2.mp3 black sabbath music3.mp3 black sabbath music4.mp3 What is wrong? |
|
|||||
|
Sorry, should have kept your original script -
The problem with your script was you changed the variable file for file in *.mp3 do newfile=`echo $file | sed 's/black\ sabbath\ //g'` file=`echo $file | sed 's/ /_/g'` mv $file $newfile done If you had not changed what you were originally looking for, it may have worked - you also needed some quotes to move the files for file in *.mp3 do newfile=`echo $file | sed 's/black\ sabbath\ //g'` mv "$file" $newfile done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|