Results 1 to 10 of 21
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 ...
- 01-26-2005 #1Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
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
- 01-26-2005 #2Linux Engineer
- Join Date
- Nov 2004
- Location
- Montreal, Canada
- Posts
- 1,267
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
- 01-26-2005 #3Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
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
- 01-26-2005 #4It'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.
Originally Posted by x0054
Registered Linux user #270181
TechieMoe's Tech Rants
- 01-26-2005 #5Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
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
- 01-26-2005 #6Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
You could write up a bash function to do it
- 01-26-2005 #7That's what I was thinking. You might be able to string together several command-line operations into a shell script.
Originally Posted by valan Registered Linux user #270181
TechieMoe's Tech Rants
- 01-26-2005 #8Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
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
- 01-26-2005 #9Linux Engineer
- Join Date
- Nov 2004
- Location
- Montreal, Canada
- Posts
- 1,267
Originally Posted by techieMoe But again that's stupid no?
Originally Posted by UgoDeschamps
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
Fairly simple took 3 line of code, hopefully this isnt that hard and not to "stupid"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-}"
\"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
- 01-26-2005 #10Just Joined!
- Join Date
- Jul 2004
- Posts
- 85
You of course realize that that does not actually work.
Perhaps I am missing something.


