Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

One of the ways I quickly rename files in Windows is

F2 > Rename > Tab (to next file) > Rename ...

But in Ubuntu/Nautilus, I cant tab to next file. But being on Linux, I think there must be a command line alternative? What will it look like

However, sometimes, I may want more control over how to rename specific files. In that case, perhaps its better to be able to tab to the next file

share|improve this question
    
Could you define "more control"? Not sure what you're asking exactly.. –  Dang Khoa Aug 25 '11 at 2:08
    
I think this question is not answered. What you are asking for (F2 and then jump in F2 mode to the next file) is currently not available I think in Nautilus. –  don.joey Jul 16 '13 at 20:14
add comment

7 Answers

up vote 55 down vote accepted

I use rename all the time. It is pretty simple, but hopefully you know basic regex:

$ rename s/"SEARCH"/"REPLACE"/g *

This will replace the string SEARCH with REPLACE in every file (that is, *). The /g means global, so if you had a "SEARCH SEARCH.jpg", it would be renamed "REPLACE REPLACE.jpg". If you didn't have /g, it would have only done substitution once, and thus now named "REPLACE SEARCH.jpg". If you want case insensitive, add /i (that would be, /gi or /ig at the end).

With regular expressions, you can do lots more. For example, if you want to append something to every file: $ rename s/'^'/'MyPrefix'/ * That would add MyPrefix to the beginning of every filename. You can also do ending: $ rename s/'$'/'MySuffix'/ *

Also, the -n option will just show what would be renamed, then exit. This is useful, because you can make sure you have your command right before messing all your filenames up. :)

share|improve this answer
    
How will I have a "dynamic" suffix. Like 001 - 010 etc. Possible? –  Jiew Meng Aug 27 '11 at 8:01
    
Hmm.. I tried to write something up but it didn't work. Mostly because, when I add 1 to 001, it adds to 2, not 002. Otherwise, I could just use varaibles to hold the number position, then append it. Also, I just remembered, before I knew about the rename commmand, this is what I did to append: for f in *; do mv -v "$f" "prependThis$f"; done –  Matt Aug 27 '11 at 13:54
2  
@jiewmeng Yes. Use (?:\.[0-9]{3})$ in your pattern, it will match all 3 digit file extensions in a passive group. Example: rename s/^my_favorite_movie.avi(?:\.[0-9]{3})$/random_movie.avi/ *. Have a look at this regex cheat sheet. –  sergio91pt Aug 30 '11 at 11:33
    
@sergio91pt it is a nice regex cheat sheet. But what it is about? Must be perl - but a can't find such a note there. –  Adobe Aug 30 '11 at 16:48
    
@Adobe Its a general one for "perl based regex". Look at the note about the + sign and the column about POSIX Character Classes. –  sergio91pt Aug 30 '11 at 18:03
add comment

Try pyrenamerInstall pyrenamer.

It's not integrated with nautilus, but it gets the job done. Here is a review.

Thunar Install thunar (part of XFCE) also has an a renamer that you can run separately.

Thunar bulk renamer

share|improve this answer
add comment

Not really the same question as What mass file renaming tools are available? but I'm going to suggest the same program that I suggested in that answer: qmv.

qmv is a handy tool from the renameutils package. It enables you to use your favorite text editor to rename files. Combined with the power of vim, you have an excellent renaming utility.

I usually invoke it like qmv -f do in the dir where I want to rename a bunch of files. Or if I want to rename recursively qmv -R -f do.

Whenever I have the need to rename multiple files, I always fall back on qmv (and vim).

http://www.nongnu.org/renameutils/

share|improve this answer
add comment

In case you want to do it without command line, similarly to what you have been doing in Windows, use right arrow key instead of tab key. This will select the next file just as tab does in Windows.

share|improve this answer
    
It is not the same: you would still need ENTER to finish renaming, arrow key to move to the next file, and F2 to rename it. TAB does it in 1 step once you are renaming a file. –  MestreLion Aug 30 '11 at 18:25
    
@MestreLion But it's very similar to algorithm described in the question and does not require neither any additional software nor command-line operations. Sort of being user-friendly. –  Rafał Cieślak Aug 30 '11 at 19:31
    
True, you were the only answer that at least tried the same approach as the original question. And the sad truth is that Nautilus has no such functionality. You can F2 to rename, but thats it. No TAB to automatically jump you to next file in rename mode already. –  MestreLion Aug 31 '11 at 5:18
add comment

In the command line, to rename a single file the command is simply

mv file1.txt file2.txt

If you want to do it in batch, you'll probably want to do it via a script. If you provide more details I or someone else can probably whip one up for you. That said, a script to append stuff to a file might look like this:

#!/bin/bash
for file in *
do
    # separate the file name from its extension
    if [[ $file == *.* ]]; then
      ext="${file##*.}"
      fname="${file%.*}"
      mv "$file" "${fname}_APPENDSTUFFHERE.$ext"
    else
      mv "$file" "${file}_APPENDSTUFFHERE"
    fi
done

Depending on exactly how you need things renamed this will likely be tweaked, for instance if you have specific renaming rules to follow. (Personally I'd do this via a Perl script since my bash-foo is not that great, but that's just me.)

Note that I got the separation of filename and extension from a previously asked question.

share|improve this answer
3  
Don't use for file in `ls`, use for file in * instead. And quote your strings. Because of this, your script is terribly broken on filenames containin spaces. And why using basename, given you are already using ## and % operators? –  enzotib Aug 25 '11 at 5:24
    
thanks, i cleaned up slightly. Frankly, I just copy/pasted that part of the code from the question I linked to in the first place –  Dang Khoa Aug 25 '11 at 6:26
1  
If you allow me, I will do some little corrections. –  enzotib Aug 25 '11 at 7:31
    
please be my guest! –  Dang Khoa Aug 25 '11 at 7:48
    
ok, done :) ... –  enzotib Aug 25 '11 at 13:20
add comment

There seems to be a project on launchapad called nautilus-renamer. You can install it by running make install once you download the script and untar it. It seems to have some functionalities or if you do know some programming may be you could just enhance it to your need as it is just a python script.

enter image description here

share|improve this answer
add comment

I'm using krename. It is a GUI app. It could read mp3 tags and so on.

It exists as a separate app as well as a part of Krusader.

There's also a rename script - which is a part of standard perl installation (You probably have it installed). Check it out with man rename.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.