LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-28-2006, 12:23 PM   #1
starwarsfan982
LQ Newbie
 
Registered: Sep 2006
Posts: 9

Rep: Reputation: 0
renaming files


I am trying to better organize my music collection. I have some files that have the name "01 - song.mp3". I want to rename them so that they are called just "song.mp3". Does anyone know how I can do this in bulk with a command line tool or program?

Thx, Starwarsfan982
 
Old 10-28-2006, 01:09 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
1. Are your files all in one directory, or are they in directories?

1a. If they are in directories, do you wish to rename the directories too?

2. Do you want to remove spaces in filenames to make it more convenient to handle them in the shell?

3. Do you wish to remove characters which may cause problems on filesystems which have restrictions on which characters may be in filenames (e.g. remove : so that files can be transferred to FAT filesystems without freaking them out)?

4. Do you wish to rename files according to meta-data, e.g. ID3 tags?

Last edited by matthewg42; 10-28-2006 at 01:10 PM.
 
Old 10-28-2006, 01:20 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
OK, for a single directory, just removing leading numbers (e.g. track numbers on mp3 files)?

If so, the "rename" command which comes with perl is really good. You need to know about perl style regular expression to understand how it works, but the usage is easy when you do. e.g.

Code:
$ rename -v 's/^\d+\s*//' *.mp3
01 Public Service Announcer.mp3 renamed as Public Service Announcer.mp3
02 Watching Xanadu.mp3 renamed as Watching Xanadu.mp3
03 Instead.mp3 renamed as Instead.mp3
04 I Tried.mp3 renamed as I Tried.mp3
05 This Is Not Who We Were.mp3 renamed as This Is Not Who We Were.mp3
06 Barcode Bypass.mp3 renamed as Barcode Bypass.mp3
07 Only I.mp3 renamed as Only I.mp3
08 Animal Cannabus.mp3 renamed as Animal Cannabus.mp3
09 Strangeways Inside.mp3 renamed as Strangeways Inside.mp3
10 Mull Historical Society.mp3 renamed as Mull Historical Society.mp3
11 Paper Houses.mp3 renamed as Paper Houses.mp3
You can remove the -v option to prevent it spewing out all this verbose output.

You can add changing of spaces like this:

Code:
$ rename -v 's/^\d+\s*//; s/\s+/_/g;' *.mp3
You can add translation to lower case like this:

Code:
$ rename -v 's/^\d+\s*//; s/\s+/_/g; y/A-Z/a-z/' *.mp3
If you don't know about perl style regular expressions, this is probably total nonsense. They're very cool, so read the perlre(1) man page without delay!
 
Old 10-28-2006, 02:42 PM   #4
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 81
Hey, I wondered if there was a way to query a cddb database again for all of a music collection and use that info to rename all of the files. Amarok does a good job of getting the music information and song names. If possible, I'd like to use the information Amarok gets to rename all of my music. Thanks.
 
Old 10-28-2006, 03:30 PM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
If you used CDDB when you backed up *cough* your music files from your CDs, the files should already contain the band, album and song titles in meta-data tags. In the case of MP3 files, these tags are called ID3 tags. This is typical behaviour for CD rippers which know about CDDB (i.e. most of them).

In this case, what you might be looking for is tagtool. If you're running Ubuntu, this is available in the Universe repository, and I'm sure it's available in other distros too.

Tagtool lets you rename files according to the contents of ID3 tags, and has a fairly nice GUI interface as well. Note that when you're renaming files which are already in directories and you want the new filenames to include new directory names, you should probably move them all to one directory first, else your new directory names will be "inside" the old directories. Work on a backup copy of your files first to make sure you know how it works.
 
Old 10-30-2006, 12:42 PM   #6
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 81
Quote:
Originally Posted by matthewg42
If you used CDDB when you backed up *cough* your music files from your CDs, the files should already contain the band, album and song titles in meta-data tags. In the case of MP3 files, these tags are called ID3 tags. This is typical behaviour for CD rippers which know about CDDB (i.e. most of them).
What about my music that is not mp3? Ogg vorbis does have tags. FLAC probably does not, but I am unsure about it. I have one album in FLAC, and probably more later. I wanted to ask you about the tags my mp3s should already have. They came from many sources. Could the tags be different? Should I re-tag them all using the same CDDB? Will a CDDB get queried again for the music that does not have tags?

Quote:
In this case, what you might be looking for is tagtool. If you're running Ubuntu, this is available in the Universe repository, and I'm sure it's available in other distros too.

Tagtool lets you rename files according to the contents of ID3 tags, and has a fairly nice GUI interface as well. Note that when you're renaming files which are already in directories and you want the new filenames to include new directory names, you should probably move them all to one directory first, else your new directory names will be "inside" the old directories. Work on a backup copy of
your files first to make sure you know how it works.
Nope, not Ubuntu. Read my info next to my name. I did find it with Apt in Debian Etch. I have a lot of software available to me. I thought the music had to be seperated to know which song is which when using the CDDB because it will take the lengths of each song to know what album it came from. Have you tried it? Thanks for telling me about it. You cleared up my confusion about tags and how mp3s get their names.
 
Old 10-30-2006, 01:00 PM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Quote:
Originally Posted by fakie_flip
FLAC probably does not, but I am unsure about it.
I don't know about FLAC.

Quote:
Originally Posted by fakie_flip
I wanted to ask you about the tags my mp3s should already have. They came from many sources. Could the tags be different? Should I re-tag them all using the same CDDB? Will a CDDB get queried again for the music that does not have tags?
...
I thought the music had to be seperated to know which song is which when using the CDDB because it will take the lengths of each song to know what album it came from. Have you tried it? Thanks for telling me about it. You cleared up my confusion about tags and how mp3s get their names.
I suppose you should make sure that all the tracks you want to rename have enough information for your naming scheme, e.g. if you're using the artist name, make sure all the files have this tag etc.

I don't know about re-tagging the files. The only tags I ever added were done at the time I was backing up from the CD, and in this case I believe the looking in the CDDB is done from information extracted from the CD's table of contents - I don't know if you can get the same info from the mp3/ogg/whatever files.
 
Old 10-30-2006, 02:06 PM   #8
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
You can add/replace tags on ogg/vorbis files with vorbiscomment (see -a, -t and -w options). Haven't come across any mp3 equivalent yet (though I'd imagine there's one around somewhere).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
renaming files TomalakBORG Linux - Newbie 4 12-24-2005 10:14 AM
Renaming files TomalakBORG Linux - Newbie 2 12-05-2005 04:13 PM
renaming files script. xushi Programming 4 10-10-2004 08:06 AM
Renaming files as they are uploaded Cr4wford Linux - Software 1 04-26-2004 03:41 PM
Renaming files in one go saurya_s Linux - Software 1 01-12-2004 01:16 PM


All times are GMT -5. The time now is 01:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration