Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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!
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
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.
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.
Distribution: Gentoo Hardened using OpenRC not Systemd
Posts: 1,495
Rep:
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.