These scripts are written to run on a Linux / Unix system. I have no interest in Windows systems. I will ignore all requests to email you a windows binary.
If you're a Linux / Unix user that's genuinely tried to solve your own problem but still have questions, I'd be really delighted to respond and help you. Likewise, if you develop a windows equivalent of what I've done here, I'd be happy to hear from you and add a reference to your work onto my pages.
From time to time, I find a certain task that would be just too tedious to perform manually. Linux and the languages that are freely available for it provide a wonderfully rich opportunity for scripting solutions to these sorts of problem.
Perhaps some of these scripts may be useful for you...
A perl script for Linux or Cygwin to recursively descend a directory tree and create mp3 versions of your m4a (AAC) music files. The nice thing about this script is that it copies your ID3 tags across too (or as many of them as the mp3 format supports). See here for a Windows version.
The m4a2mp3 script takes a command line argument specifying the root of the directory tree of music files. The script will descend and convert all .m4a files within the tree into .mp3s, with all .m4a tags being converted into id3v2 tags in the .mp3 files.
After several years buying digital music instead of CDs (and ripping all my CDs onto the hard drive anyway), I've accumulated more than ten thousand tracks. It's very difficult to manage your music if its all installed in one directory.
As written, the script assumes that the hierarchy of your music directory conforms with the following structure. You can modify the script to suit your own hierarchy.
GENRE/Artist_or_Composer/Album_Name/Optional_Disc_number/Track_Name (Disc number in the form "disc_n" where n is the disc number) (Classical and Opera genres will tag the Composer. Others will tag the Artist)
GENRE/Compilation/Album_Name/Optional_Disc_number/Track_Name GENRE/Compilation/Artist_or_Composer/Album_Name/Optional_Disc_number/Track_Name (The name "Compilation" will ensure that albums under this directory are handled appropriately.)
Track names are assumed to start with two digits and an underscore (indicating track number) e.g. 02_Happy_Birthday.m4a.
Note that because of some limitations of regexp string searching (used by Perl), the filenames of your music will need to be sanitised before this script will work. Spaces need to be converted to underscores and some special characters need to be removed. The fix_tags script has a little file renaming built-in, but it will not rename directories which contain space and other special characters. The rename files script below will do this for you.
This Linux or Cygwin perl script recursively descends a directory tree and fixes all MP3 and M4A (AAC) tags in music files so that the tags conform with your naming policy. For example, the script will remove multiple spaces, capitalise the first letter of each word, insert apostrophes in appropriate words that should contain apostrophes, unify the naming of key signatures in classical music and so on. See here for a Windows version.
I've found the best use of this script is to reclassify my music by renaming the Genre appropriately. If I decide that a piece of music is "ROCK" instead of "POP", all I do is drag the music from under the "POP" genre and put it under the "ROCK" genre, then run this script on the directory. Also, if the mp3 or m4a file is not tagged appropriately with the track number, total tracks, disc number or total discs, this script will correct tag errors or add new tags for these fields automatically too.
This Linux or Cygwin perl script recursively descends a directory tree and rename files according to a policy specified within the script. You can edit this script so that it does what you want. See here for a Windows version.
For example, spaces within filenames are converted to underscores; special characters such as '+' are removed or renamed to something else. You should check the source code and adjust to suit your requirements, however as written, it will prepare directory and file names so that the fix_tags script will work properly.
The script takes two parameters. The first is a pointer to the root of the directory tree from which the script will descend. The optional second parameter is the word 'commit'. If you don't include 'commit', the script will simply tell you what it would have done but not do it. If there are spaces in directory names and you don't commit, the script deliberately doesn't check and report on what its going to do with the files below that directory because the spaces confuse it.
This Linux or Cygwin perl script recursively descends a directory tree and sets all file and directory permissions to specified values.
A Linux or Cygwin shell script to recursively descend a directory tree and remove garbage files,
A Linux or Cygwin shell script to copy an entire directory tree from one location to another,
A Linux or Cygwin shell script to copy only those files which have changed in an entire directory tree from one location to another, Essentially, this is the same as cp-tree.sh above, but it won't copy files which already exist in the target destination tree unless the version of the file in the source tree is different. I use this script for backing up changes to my media directories without having to copy the entire media directory every time.
A Linux or Cygwin shell script to check to see which kernels are installed on your redhat system and remove all old kernels to save hard drive space,
I discovered that when I used Linux command line tagging tools to change the tags on my m4a music files, the tags were written back to the file in the wrong order. The files still played using mplayer and itunes (off the local hard drive) but could not be shared over my LAN. This quick and dirty tool fixed the atom order so that the tags were in the right place for streaming.
Read the notes on my photo album scripts for some hints about getting Cygwin installed and running on your Windows computer.
One or two of the perl scripts above make use of some perl libraries which you need to make sure you install. The Windows perl scripts (and their Linux counterparts) don't need these libraries.
Installing perl libraries is trivial. Start by typing the following at a shell prompt (in either Cygwin or Linux)...
perl -MCPAN -e "shell"
You'll be asked many configuration questions the first time you do this but subsequent times will pick up the data you entered the first time. Select defaults for all questions until you're asked for a mirror site near where you live. Choose one close to your location.
When the initial configuration formalities are complete, you will see the "cpan>_" prompt. You can now install the first of the required libraries as follows...
cpan> install URI::Escape
You'll see the module downloaded, configured, installed and tested. The process takes about a minute and the size of the download is small.
When it's done, you'll see the "cpan>_" prompt again and you can install these additional libraries used in the m4a2mp3 script...
install MP4::Info install MP3::Info install MP3::Tag
Finally, just type...
...to return to the Linux or Cygwin shell. My scripts will now run properly without complaining about the missing libraries.
For your convenience and to save you the need to install and run a windows compiler yourself, I've packaged binaries of faad, faac, mp4info, mp4tags, id3v2, lame and m4a_optimise along with the DLLs which they require and the fix_tags.pl, generate_playlist.pl, m4a2mp3.pl and hack_filenames.pl scripts into a Windows zipfile.
The README in the zipfile also provides information about where you should copy the files on your Windows system.
Note: You will need to install ActivePerl for Windows in order to run these Windows scripts. Google for ActivePerl to find its freely downloadable installer.
Stefan Keller-Tuberg. August 2006.
Return to my home page.