Kangry.com [insert cool graphic here]
home | Topics | Logout | Search | Contact | ?? Kangry ?? | Bandwitdh



New user

uploaded files
(linux_command_line)-> (Parent)->linux rename command+examples submited by Russell Tue 31 Jan 06
Edited Sun 06 Dec 09
Web kangry.com
(not all renames are created equal Alt version here)
to rename a single file just use move (mv):
mv oldfilename newfilename
To rename a bunch of files in the same way use rename
rename from to filespec
replaces all from with to in all the files that fit filespec
say you have a list of files:
to rename these files all at once use:
rename DSCF xmas_photos DSCF*
this will rename the files so you now have:
To delete text from the filenames use:
rename something_to_delete "" filespec
This can also be used to cut the extension from the file name:
rename .JPG "" *.JPG
Or to rename one extention to another
rename .jpeg .jpg *.jpeg
But to do this, you must issue the command for each type of extension that you have (.JPG, .jpg, .jpeg etc )

To rename filenames with spaces to filenames without spaces:
rename " " _ *\ *
Will change spaces in filenames to underscore. (note there is a space after the blackslash in the last parameter of that command) Repeat this command until you get :
rename: renaming * * to *_* failed: No such file or directory
because it only changes the first occorance of the space in the filename. Be Mindful of the warning below


This WILL overwite files without warning you. say you have files:
And you use the command (I know this is silly but it makes the point):
rename other_file aa *.txt
this will overwrite without warning aa.txt with other_file.txt, leaving only one file named aa.txt. To avoid this gotcha, I usualy move all the files that I want to rename into a temp directory ( or copy them if I am felling really paranoid ) and do the rename there. The command does not appear to support an interactive option like mv -i ( prompt before overwrite )
Dec 6,2009
Sadly all renames are not created equal. I just installed ubuntu on my latop and discovered that the rename command is different. The version installed on ubuntu uses a perl replace method, which is much more powerful. what is bad about this is that the command's behavior is Different for the various versions.

First : Which version do you have installed?
type man rename. if the top of the page says
Perl Programmers Reference Guide
you have the perl version. If it says:
Linux Programmer's Manual
you have the standard (older) version. use the notes above for this command. if you have the perl version the paramters are different. They look like this:
rename 's/\.bak$//' *.bak
the quotes and the s are required. the format is 's/FROM/TO/' so the from and to values are in the first paramter instead of the first two. It's not that complicated, and using perl regeular expressions it is quite powerful. What I do not like is that any script that uses the old format will need to be updated.

rename (Anonymous)
Nice (Anonymous)
Nice (Anonymous)
rename files (Silvio)
thank you (Fred)
rename - prefix (Anonymous)

Add comment or question...:
Submited by: NOT email address. Leave blank for anonymous    (Spam Policy)

Enter Text: (text must match image for posting)

This file (the script that presented the data, not the data itself) , last modified Wednesday 03rd of December 2014 09:40:39 AM
your client: CCBot/2.0 (http://commoncrawl.org/faq/)
current time: Wednesday 26th of April 2017 03:27:18 PM