Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

my files are of the form War of the World - H. G. Wells.pdf I would like Wells H G - War of the Worlds.pdf There are several other file extensions epub, mobi etc. Is there a package that will do this - in bulk? Any help greatly appreciated. Thanks

I should add that I have pyRenamer already. Most files are of the format Title - Author.ext eg Harry Potter blah de blah - J.K.Rowling.pdf or Some Other Title - Firstname Surname.epub

What I would like is Surname Firstname - Title.ext (os is Ubuntu 12.04LTS) tia

share|improve this question

You can use the perl-based rename command: based on the 3 examples you have given so far, something like

rename 's/(.*)\s+[-]\s+(.*)\.(.{3,4})/$2 - $1.$3/' *.*

should work however test it first by adding the -n and -v options i.e.

$ touch "War of the World - H. G. Well.pdf"
$ touch "Harry Potter blah de blah - J.K.Rowling.pdf"
$ touch "Some Other Title - Firstname Surname.epub"
$ rename -nv 's/(.*)\s+[-]\s+(.*)\.(.{3,4})/$2 - $1.$3/' *.*
Harry Potter blah de blah - J.K.Rowling.pdf renamed as J.K.Rowling - Harry Potter blah de blah.pdf
Some Other Title - Firstname Surname.epub renamed as Firstname Surname - Some Other Title.epub
War of the World - H. G. Well.pdf renamed as H. G. Well - War of the World.pdf

See man rename for usage

share|improve this answer

I think this is the easiest and readable way:

 mmv -v "* - *.pdf" "#2 - #1.pdf"

Here is a test:

$ ls
title - author.pdf  TITLE - AUTHOR.pdf  World - H. G. Wells.pdf
$ mmv -v "* - *.pdf" "#2 - #1.pdf"
TITLE - AUTHOR.pdf -> AUTHOR - TITLE.pdf : done
World - H. G. Wells.pdf -> H. G. Wells - World.pdf : done
title - author.pdf -> author - title.pdf : done
$ ls
author - title.pdf  AUTHOR - TITLE.pdf  H. G. Wells - World.pdf
share|improve this answer
This worked for me. Thanks very much. Tom40 – Tom40 Sep 26 '13 at 19:59

Yes, pyRenamer Install pyRenamer.

It is not very hard to figure out. I use it.

First select the folder where your files are located; they're usually located in the home user name or media then under insert/delete tab you can type what you want to add. There's a small icon option button up at the top right this will allow you to select all files and keep the file extension.

Then, hit preview after typing in what you want to add at the beginning if the check box is not checked and at end if it is.

If it looks good, hit rename, and you're done.

There are many more features. If you hover you mouse over stuff, a help box will appear.

share|improve this answer
Could you explain how to use it. I don't know :( – Braiam Sep 21 '13 at 15:38
First select the folder where your files are located then – user194670 Sep 21 '13 at 16:37

Your Answer


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.