Click here to download Version 3.0 for Mac/Windows

Click here to download Version 2.0 for Mac/Windows

 

New for Version 3.0 (04/2012): International character bug fixed. "No-GUI" mode adds your music as soon as you download it e.g. with 'Hazel'. New 'natural sort' track ordering for numbered tracks. Smarter default settings for folders. 'Are you up to date?' version checking.

New for Version 2.0 (04/2012): Faster! (approximately twice as fast as V1.1).
New 'Move/Copy' option. New 'Reverse Order' option. GUI layout has been improved.

This software lets you add music albums to iTunes without them becoming jumbled up when viewed according to 'Date Added'. The program adds music slowly and predictably to iTunes. Each album is added separately in order, and each track within each album is added in the correct order. The program pauses every 200 tracks to allow iTunes to do any housekeeping work it wishes to.

However, adding things 'neatly' to iTunes means it can take 10-20 seconds to add an album instead of 5-10 seconds. The program is best suited for neatly adding anywhere between two albums and a few hundred. If you are merging two giant libraries, and you don't want to leave this program running overnight, you may need to find a different solution - or perhaps just learn to live with a jumbled-up iTunes library.

*Note for Mac users: a few people have had problems running the Mac Application version on some versions of MacOS. If you get an error message, go into the "Src" folder, and run the '.command' version of Add My Tunes.

Verified by Softpedia as a safe download.

Who might this solution be useful for?

  • Anyone who has got some music from Jamendo or Amazon and wants to add it to their collection.
  • Anyone who wants to use another encoder (e.g. LAME) to encode new CDs before adding to iTunes.
  • Anyone who has a collection on a second computer and wants to merge it with their main collection.
  • Romantic couples who wish to express their commitment by combining their music collections. :o)

To use this program

To use the program: Start by opening iTunes. Then download the software, and run either the App, or the .exe according to the system you're using (Mac/Windows). When the program opens, click the top button and select the folder with music to be added. Click the second button and select the 'Automatically Add to iTunes' folder, which is hidden inside your iTunes music library along with all the band names**. Click the third button and the program will start running. If you need to stop the program, there's a cancel button and a progress indicator. The program works 'recursively' which means that if you have a lot of stuff to add, you can bundle it up in one giant folder and it will all be added together.

** Windows: My Documents\My Music\iTunes\iTunes Media\Automatically Add to iTunes
** MacOS: (Home directory)/Music/iTunes/iTunes Media/Automatically Add to iTunes

The program assumes that each music album is currently kept in a separate disk folder. Anything similar to e.g. 'mp3folder/album1/...' or 'mp3folder/artist1/album1/...' or even simply 'album1/...' will be OK. It also assumes filenames have the track number at the start (e.g. iTunes style). If they don't, then albums will be grouped together but tracks may not be in original track order (they may be in alphabetical order instead).

e.g. A folder structure like "Music_To_Add/Revolution Void/Thread Soul Album/02 BioMythos.mp3" is ideal.

Tips:

  1. If you're leaving it running overnight, I recommend leaving iTunes as the 'foreground' application while the adder program is running. I also recommend closing any programs that need a lot of CPU power - iTunes can go to 99% CPU utilisation when it's adding files.

  2. It may be worth placing a shortcut/alias on your desktop for the 'Automatically Add to iTunes' folder**.

  3. To fix old 'mixed up' albums in iTunes, you could copy out the folder from the iTunes Music folder (where it will be stored in folders by artist and album). Next, delete the old entries in iTunes, and then finally re-add the music folders with this program to place things in the correct order.

  4. You should clear out the 'Not Added' iTunes folder from time to time; non-music files will end up there.

  5. You can adjust the radio buttons if you want to try to find faster settings. On MacOS I found 20s/0s delays worked perfectly. On Windows, I found 20s/1s was better. Your mileage may vary.

Please note that this program moves files around on your computer, and that iTunes will delete files as they are being added. I provide no warranty whatsoever for this software or its behaviour. Please note that by choosing to use this program you take all responsibility for any lost/damaged data. Backup your data. With that said: You can read the source code and check for errors if you like. I've tested the program many times and I haven't found any faults in the latest version. I use this for my own music collection and haven't lost or damaged any data.

Long-winded explanation of why I wrote this program

The 'Date Added' problem that is solved here is an annoyance for all those people who use 'Sort by Date Added' to look through their iTunes library and play their most recent album purchases. The symptoms of the problem are that tracks for two or more albums will be displayed mixed up together; and tracks within each album may also be presented/played in the wrong order.

You could argue that the 'Date Added' feature shouldn't be used to sort albums. However, the fact is that many people have used it this way for a long time to simultaneously a) sort music into albums and b) view recently purchased albums before older ones.

The problem is caused by iTunes importing music in an unpredictable/random order when a group of mp3s is either dragged-and-dropped into the GUI, or added using 'import folder', or placed into the 'Automatically add to iTunes' folder on the hard drive. This problem doesn't exist if you add music by importing from CD. It seems like iTunes adds files in a partially-organised, partially-random way.

The program works by going into each album folder and copying the files one by one to the iTunes folder. It waits for iTunes to remove the file from the "Auto Add" folder, then pauses briefly (this is important for e.g. fast computers to prevent occasional song ordering mixups), then continues to copy the next file. It also pauses every 200 songs because iTunes sometimes seems to slow down when many songs are being added - iTunes may even lock up. It appears to need time for some housekeeping operations. The lengths of the pauses can be user controlled. Music arranged in a single folder (e.g. by artist) will be copied together, album by album. Once the albums are copied, music files that are not in an album will also be copied over separately.

Other solutions

  1. Some people add their albums into iTunes one at a time by hand to avoid the "Date Added" album mixup problem. This also works, but it is quite boring as it requires a lot of manual work if you are combining two large libraries. Also, it doesn't prevent the tracks within the album from being added in the wrong order.

  2. Some people use XML-editing heuristics that try to automatically fix the iTunes library file into the right shape. This apparently works OK and can be quite fast, but I believe these tools are limited to Windows. Also, if the mixup you want to fix is near the end of a large XML file, you may be waiting a while. I will admit that I personally am not keen to muck about with the dark mysteries of the XML database used by iTunes, in case there are unexpected consequences following future updates to iTunes. That's why I wrote this tool. But if you want to try the other route, here it is. It seems reasonably well-supported by the author.

Development of the program

Looks like a simple problem, right? It would be, except for several evil race conditions.

'Race conditions' are situations when two programs are fighting over data to see which can use it first - and the data can become corrupt (or deleted). They made writing this program much more of a pain than I had initially expected. If you try to add more than one file at a time via the 'automatically add to iTunes' folder, you have no guarantees about when iTunes will decide to start adding/copying/deleting them, the order in which they're added/deleted, whether it may delete an entire 'to add' folder while you are still trying to copy files into that folder, or when housekeeping tasks will run (such as deleting non-MP3 files & folders, and running 'gapless playback analysis).

My favourite race condition? Possibly when iTunes deletes the album folder while I'm still moving files into it (how do you lock a folder in a cross-platform way?)... or possibly, when iTunes deletes a file while the standard Python copy routine is trying to set permissions on it as part of the copying process. Both of these problems are now resolved. iTunes itself is not super-robust, either - it froze up repeatedly on me when I added many files without pausing.

I tried 4 or 5 different copying routines intended to run faster than this version, before I gave up and accepted it was not worth the effort; hence the simple routine used here. Saving a few minutes on a very infrequently performed task really isn't important, compared to the risks of losing or damaging your data. So, please wait patiently and don't take risks by modifying this program to run faster... it's probably not worth the effort.

Testing

If you want to test the program, you can do something like this:

  1. Open a bash prompt.
  2. Create a bunch of files and folders.
  3. Run the program and move the files from a 'source' into a 'destination' folder.
  4. Check that files were being moved in groups in the right order.
  5. Delete the test files.

For (2) and (3), you can use this code.

$  mkdir test-source test-dest test-dun; cd test-source
$  for i in {1..10}; do mkdir $i; for j in $((i)){101..140}; do 
      dd if=/dev/zero of=$i/$j bs=4m count=1 ; done ; done     #makes 400 files
$  cd ../test-dest
$  while true; do sleep 1; ls; mv -f * ../test-dun 2>/dev/null ; done   #simulates iTunes 

You may also want to add in a few ".DS_Store" files, empty folders etc if you want to test the program logic.

License

This software is licensed under the Gnu Public License (GPL3). If you make a change that improves the program, the GPL license means you need to share all your source code publicly if you provide copies of the program. You may not claim to be the original author. I'd be grateful if you could email me any suggestions & improvements (see here for my email). Thanks!

Add My Tunes
Copyright (C) 2011 Graeme Bell

This software is used at your own risk; by using it you accept that the author 
is not liable for any unexpected problems, damage or loss of data.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Version History

1.0 Initial release. Sep 2011

1.1 Added radio buttons to control pauses; tidied up GUI; fixed Tkinter open focus on MacOS. Oct 2011

2.0 Faster (twice as fast as v1.1). GUI layout improved. Code restructured. New 'Move/Copy' option. New 'Reverse Order' option. April 2012.