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 HostsFree MagazinesJobs
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   #1 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 80
Using the Rename Command?

Yes I did read the man pages and I can not figure out how to do something. I have a list of files wls01 wls02 wls03 .... etc. I need to rename them to wls01.mp3 ... etc. Basically I need to add a .mp3 extension to all files that start with wls. The command I tried to use is as such:

rename wls** wls**.mp3 wls**

But it does nothing. No errors, nothing. What's wrong. How would I go about doing this?

- Bogdan
x0054 is offline  
Old 01-26-2005   #2 (permalink)
Linux Engineer
 
Join Date: Nov 2004
Location: Montreal, Canada
Posts: 1,271
I never used this renaming command.

I may be wrong, but this command (like you've put it) cannot be done it this sense.

Renaming a file must be done to a specific name... so wls**.mp3 doesnt meen nothing to the command line.

Unless im on crack, this cannot be executed as-is...

There is a solution thou... its called bash command.
__________________
\"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   #3 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 80
Don't you think that's kind of stupid. This thing that I am trying to do is quite commonly done, especially on webservers. There has to be a way to do this the easy way. On win copy wls* wls*.mp3 would do the trick. I refuse to believe that it would, or should be harder on linux.

- Bogdan
x0054 is offline  
Old 01-26-2005   #4 (permalink)
Super Moderator
 
techieMoe's Avatar
 
Join Date: Aug 2004
Location: Texas
Posts: 8,696
Quote:
Originally Posted by x0054
Don't you think that's kind of stupid. This thing that I am trying to do is quite commonly done, especially on webservers. There has to be a way to do this the easy way. On win copy wls* wls*.mp3 would do the trick. I refuse to believe that it would, or should be harder on linux.
It's common for people to refer to something they aren't familiar with as "stupid". Perhaps there's another command that's more commonly used on Linux. To rename files, for instance, I use the mv command. I'm not entirely sure if it would work for wildcards, but it's worth a shot.
__________________
Registered Linux user #270181
TechieMoe's Tech Rants
techieMoe is offline  
Old 01-26-2005   #5 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 80
I did not mean that linux is stupid Just me being pissed after trying to do this for few days now.

Yeah, I tried mv, the problem is mv can not move multiple files to multiple destinations, it can only move a file to a destination or multiple files to a destination directory. Thus mv could be used like this:

mv wls* newdir/

but not like this:

mv wls* wls*.mp3

In using the rename command I need a way to append the name instead of changing part of it, and in that lies the problem

- Bogdan
x0054 is offline  
Old 01-26-2005   #6 (permalink)
Linux Engineer
 
Join Date: Nov 2004
Posts: 785
You could write up a bash function to do it
valan is offline  
Old 01-26-2005   #7 (permalink)
Super Moderator
 
techieMoe's Avatar
 
Join Date: Aug 2004
Location: Texas
Posts: 8,696
Quote:
Originally Posted by valan
You could write up a bash function to do it
That's what I was thinking. You might be able to string together several command-line operations into a shell script.
__________________
Registered Linux user #270181
TechieMoe's Tech Rants
techieMoe is offline  
Old 01-26-2005   #8 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 80
I know, and that's not a problem, I can write a loop for it if I wanted to. I just think that I should not have to. I can not believe that something so simple should take half a page of code to do. And I do this all the time, so would probably try to write a generic version, and that's going to be longer.

- Bogdan
x0054 is offline  
Old 01-26-2005   #9 (permalink)
Linux Engineer
 
Join Date: Nov 2004
Location: Montreal, Canada
Posts: 1,271
Quote:
Originally Posted by techieMoe
Quote:
Originally Posted by valan
You could write up a bash function to do it
That's what I was thinking. You might be able to string together several command-line operations into a shell script.
Quote:
Originally Posted by UgoDeschamps
There is a solution thou... its called bash command.
But again that's stupid no?
sorry to sound ironic mate but if it was that stupid wouldnt be the one giving the answer and not asking for it?

the answer is, No it's no dumb, stupid or strange... as Microsoft windows simply made a "nicer" version of "CP" It doesnt take a full page to write this. I'll explain the very simple algorith behind all this, and you'll be able to use it in no time

Code:
I have some files in a directory, called
prefix-file1, prefix-file2, etc

lets rename them to 
file1.mp3, file2.mp3, etc

for file in prefix-* ; 
do
mv "$file" "${file##prefix-}"
Fairly simple took 3 line of code, hopefully this isnt that hard and not to "stupid"
__________________
\"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   #10 (permalink)
Just Joined!
 
Join Date: Jul 2004
Posts: 80
You of course realize that that does not actually work. Perhaps I am missing something.
x0054 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
 

Free Magazines
Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe
Systems Management News, the newspaper for IT systems administration and data center managers!
Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe
The Enterprise Newsweekly
eWeek is the essential technology information source for builders of e-business.
subscribe
Oracle Magazine
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe
Total Telecom
Total Telecom is "The Economist of the communications industry".
subscribe
More free magazines »



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




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

Content Relevant URLs by vBSEO 3.2.0