Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Misc
Reload this Page Using the Rename Command?
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Misc Any questions or Linux discussion that does not fit in any of the other technical areas.

Closed Thread
 
Thread Tools Display Modes
Old 01-26-2005   #11 (permalink)
Workaphobia
Linux Newbie
 
Join Date: Nov 2004
Location: New York
Posts: 150
I would use find.

Code:
find -name "wls*" -exec mv '{}' '{}.mp3' ';'
I may have screwed up the {} and ; substitutions - they may need a backslash in front, or they may not need to be quoted, etc. But that would do it - you find all files named in that pattern and then execute a command on each.
__________________
\"Nifty News Fifty: When news breaks, we give you the pieces.\" - Sluggy Freelance
Workaphobia is offline  
Old 01-26-2005   #12 (permalink)
loft306
Linux Guru
 
loft306's Avatar
 
Join Date: Oct 2003
Location: The DairyLand
Posts: 1,667
hmmm there is a rename command? i never knew that....i just use mv (move) probably still will less letters...less typing
__________________
~Mike ~~~ Forum Rules
Testing? What's that? If it compiles, it is good, if it boots up, it is perfect. ~ Linus Torvalds
http://loft306.org
loft306 is offline  
Old 01-26-2005   #13 (permalink)
x0054
Just Joined!
 
Join Date: Jul 2004
Posts: 80
Quote:
find -name "wls*" -exec mv '{}' '{}.mp3' ';'
Cool, that works Thank you.

Quote:
hmmm there is a rename command? i never knew that....i just use mv (move) humph.
rename works grate if you have hundreds of blah.cgi files and you need to rename then to .pl, or things like that. Works grate for most things.... not this one apparently though.

Thanks for help,

- Bogdan
x0054 is offline  
Old 01-26-2005   #14 (permalink)
UgoDeschamps
Linux Engineer
 
Join Date: Nov 2004
Location: Montreal, Canada
Posts: 1,271
Well yes I know it doesnt work as this was only an exemple : i dont like to give THE answer... since finding it yourself you'ld prove much more efficient

Code:
#!/bin/bash
echo "Starting conversion process..."
for i in wls* ; 
do
cp "$i" "$i.mp3" 
echo "Conversion process completed..."
done
CP will make another copy of the file (I recommend if you need the original)
MV will replace the current filename with the new one
__________________
\"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
\"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps
UgoDeschamps is offline  
Old 01-26-2005   #15 (permalink)
x0054
Just Joined!
 
Join Date: Jul 2004
Posts: 80
Ok, that make sense. Sorry about that the ${file##prefix-} part through me off. I was not sure what to do with that. So woud ${file##prefix-} be set to everything after prefix- in the $file variable?

Thanks for help,

- Bogdan
x0054 is offline  
Old 01-26-2005   #16 (permalink)
UgoDeschamps
Linux Engineer
 
Join Date: Nov 2004
Location: Montreal, Canada
Posts: 1,271
actually, this line, remove "##" the "prefix-" from the filename...

prefix-file1
prefix-file2
~~~~~~~~~~~~~~~~~
would be
file1
file2

${file##prefix-}
$ = file name
file##prefix-
file = filename
## = remove
prefix- = what to remove from the fileName
You understand?
__________________
\"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
\"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps
UgoDeschamps is offline  
Old 01-26-2005   #17 (permalink)
x0054
Just Joined!
 
Join Date: Jul 2004
Posts: 80
ahh, I think so. Any good tutorials on what I assume is string manipulations? This looks like useful thing to learn.

- Bogdan
x0054 is offline  
Old 01-26-2005   #18 (permalink)
UgoDeschamps
Linux Engineer
 
Join Date: Nov 2004
Location: Montreal, Canada
Posts: 1,271
here's a little something that should get you on the go...
__________________
\"Meditative mind\'s is like a vast ocean... whatever strikes the surface, the bottom stays calm\" - Dalai Lama
\"Competition ultimatly comes down to one thing... a loser and a winner.\" - Ugo Deschamps
UgoDeschamps is offline  
Old 01-27-2005   #19 (permalink)
valan
Linux Engineer
 
Join Date: Nov 2004
Posts: 785
Heh, I never knew about a rename command for Linux. But apparently it's there, I read the man page for it. It's simple to use, too, but not like the one for DOS. Say you have a bunch of .text files, but want to rename them to .txt: 'rename .text .txt *.txt'. The first argument is the original file type, the second is the new one, and the third is all the files you want to rename. So you can't just do 'rename monkey.apple cheese.zebra' and expect it to work, because it won't. Read the man page for more info, it's real short and sweet too.
valan is offline  
Old 06-18-2008   #20 (permalink)
linny
Just Joined!
 
Join Date: May 2006
Posts: 11
Quote:
Originally Posted by UgoDeschamps View Post
here's a little something that should get you on the go...
The link doesn't work for me.
What activate link does it refer to?
I get this message.
System Error: Module is not active
Unable to find Base Info for Module: guides
Explanation:

A module was called that has not yet been activated/installed. Use the activate link in the modules module (Modules->ViewAll) to install modules.

This topic I find of great interest.
I am especially interested in removing repetative parts of multiple filenames.
I am talking about bulk renaming.

Example is
abc-two_first.mp3
abc-two_second.mp3
abc-two_third.mp3

How do I remove abc-two_ from all the filenames?
Is the rename command best for this,or mv?
Or a combination of both commands put into a script?
linny is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 11:02 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0