How to bulk rename files

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read this

How to bulk rename files

Postby miez on Mon Jan 30, 2012 4:55 am

Hi guys,

Does anyone know how to rename a lot of files at once in Linux? I have for example files called 01file.mp3 and 01test.mp3. I want to rename the files, so that the "01" is removed and the files will be like file.mp3 and test.mp3.

I've got over 500 mp3's wich I have to rename. So doing this by hand is causing a little too much time . :?
miez
Level 1
Level 1
 
Posts: 28
Joined: Thu May 27, 2010 2:47 am

Linux Mint is funded by ads and donations.
 

Re: How to bulk rename files

Postby viking777 on Mon Jan 30, 2012 5:42 am

Assuming you are using the nautilus file manager this script would probably do it:

http://www.webupd8.org/2009/12/nautilus ... cript.html

If you are not using Nautilus just google "bulk rename" along with the name of the file manager you are using.
Fujitsu Lifebook AH532 Laptop. Intel i5 processor, 6Gb ram, Intel HD3000 graphics, Intel Audio/wifi. Realtek RTL8111/8168B Ethernet.Ubuntu12.10 (Unity), Mint14 (Cinnamon), Manjaro (Xfce).
Image
User avatar
viking777
Level 13
Level 13
 
Posts: 4916
Joined: Mon Dec 01, 2008 11:21 am

Re: How to bulk rename files

Postby doktornotor on Mon Jan 30, 2012 5:54 am

Code: Select all
$ for i in $(ls /path/to/your/mp3/collection); do mv "$i" "${i:2}"; done


(Assuming that all the files are dumped in one directory.) Kindly note that you must not have any filenames that only differ in the ## prefix. Otherwise, you will get a nice cleanup of your collection. :P

Example result:

Before:
Code: Select all
$ ls
01test01.mp3  02test02.mp3  03test03.mp3  04test04.mp3  05test05.mp3


After:
Code: Select all
$ ls
test01.mp3  test02.mp3  test03.mp3  test04.mp3  test05.mp3
doktornotor
Level 4
Level 4
 
Posts: 211
Joined: Mon Jan 23, 2012 6:28 pm

Re: How to bulk rename files

Postby miez on Mon Jan 30, 2012 8:13 am

Tested and worked. Thanks a lot guys.
miez
Level 1
Level 1
 
Posts: 28
Joined: Thu May 27, 2010 2:47 am

Re: How to bulk rename files

Postby tenfoot on Mon Jan 30, 2012 3:35 pm

I installed pyRenamer and it works perfectly. It is in the Repositories.
tenfoot
----------------------------------------------------------------------------
There's so much bad in the best of us
And so much good in the worst of us
That it ill behoves any one of us
To judge even the least of us.
User avatar
tenfoot
Level 5
Level 5
 
Posts: 511
Joined: Sun Jun 03, 2007 4:12 am
Location: Waipapa, Bay of Islands, New Zealand

Re: How to bulk rename files

Postby Midnighter on Sat Feb 04, 2012 3:52 pm

Used pyRenamer at one point, but Gprenamer has far more options, and feels just that bit more ... well, it works great. :)
If you accept - and I do - that freedom of speech is important, then you are going to have to defend the indefensible. That means you are going to be defending the right of people to read, or to write, or to say, what you don't say or like or want said.
User avatar
Midnighter
Level 6
Level 6
 
Posts: 1294
Joined: Tue May 22, 2007 1:52 pm
Location: Western Australia


Return to Other topics

Who is online

Users browsing this forum: No registered users and 2 guests