Results 1 to 6 of 6
mv *.php.new *.php
doesn't give the result I want - all files ending in php.new renamed with same name and ending .php. What's the easiest way to do it?
Thanks
...
- 06-17-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 5
renaming lots of files
mv *.php.new *.php
doesn't give the result I want - all files ending in php.new renamed with same name and ending .php. What's the easiest way to do it?
Thanks
Tony
- 06-17-2010 #2
Correct. The "mv" command takes a list of current files and a single destination. If that destination is a directory, they are moved into the directory; otherwise, they are simply renamed to that last argument. It can be dangerous
.
What you actually want is the rename command:
rename(1): Rename files - Linux man page
In your particular instance:
Code:rename .php.new .php *.php.new
DISTRO=Arch
Registered Linux User #388732
- 06-17-2010 #3Just Joined!
- Join Date
- Jun 2010
- Posts
- 5
Cabhan:
Thanks. Can't see what I'm doing wrong:
rename .php.new .php *.php.new
syntax error at (eval 1) line 1, near "."
Tony
- 06-17-2010 #4Linux Guru
- Join Date
- Oct 2007
- Location
- Tucson AZ
- Posts
- 1,939
The command cabhan suggested works. You need a space after the second php and before the asteerisk (*) which it doesn't look like you have in your post and would make sense with the error message you posted.
- 06-18-2010 #5
Ah. There are two versions of the "rename" command out there: you may have the other one. Run the command:
from the terminal, and you'll see the man page for yours. It may talk about using a Perl regular expression: that's the other version of rename. For that one, the command would be:Code:man rename
On the other hand, if it's the same rename that I posted earlier, I don't know what to tell you <_<.Code:rename 's/\.php\.new/.php/' *.php.new
DISTRO=Arch
Registered Linux User #388732
- 06-18-2010 #6


Reply With Quote
