Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Move iTunes audio files between hard drives via script Apps
Did you ever have the problem that the internal hard drive of your laptop can no longer hold all your audio files? Ever looked for a way to move (not copy!) audio files between different hard drives without iTunes losing touch with the library?

I did, and I couldn't find anything on the web, so I wrote my own script (502KB download) to do the job. Please use the script with care! I cannot be sure it works on your setup. It is extensively documented, so please, read everything and customize as necessary prior to running.

[robg adds: I have not tested this script; I just made sure the code compiled on my machine and read some of the comments. As noted above, this will do some serious things to your music library, so you'll want to be certain you've got a recent backup, just in case!]

Oct 27 Update: New script uploaded...
    •    
  • Currently 2.75 / 5
  You rated: 4 / 5 (4 votes cast)
 
[22,438 views]  

Move iTunes audio files between hard drives via script | 32 comments | Create New Account
Click here to return to the 'Move iTunes audio files between hard drives via script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
How does it work?
Authored by: jspivack on Sep 28, '05 08:17:54AM

Would you mind explaining briefly how it works, and what it's doing? I can't follow all of the code all the way through...This is definitely a potential solution to my problem, so I would like to try it out - but I'd like to know what it's doing first.

Thanks
Jeff



[ Reply to This | # ]
How does it work?
Authored by: DeltaTee on Sep 28, '05 08:44:48AM

I am intersted in just the relinking part and how it is being done...I just can't find it in the code. An overall explanation of what the script is doing would be much appreciated.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: DaveA on Sep 28, '05 09:05:39AM

Check out "Put This Where I Want It" at Doug's iTunes Scripts.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: DaveA on Sep 28, '05 09:07:08AM

Ooops; the link got lost in my last post:

http://www.dougscripts.com/itunes/scripts/scripts07.php?page=3#putthiswhereiwantit



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: DeltaTee on Sep 29, '05 04:01:00AM

Note that this script will make a copy of the tracks where you want them, but they will be a copy and will not be attached to iTunes in any way. The tricky part of the whole script is the reattachment process...the location of the track is not writable though applescript. I believe (though I am having trouble wading through the code), that this script does the move then attempts to play the new tracks. This will cause the error dialog that the track can't be found, which the script then navigates through the choose file dialog to make the reattachment happen automatically.



[ Reply to This | # ]
No go
Authored by: ever on Sep 28, '05 11:02:49AM

This doesn't compile in my script editor. No offense, but I think OSXHs should put a cap on how many lines of AS they run per entry, heh. Just my op.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: nmerriam on Sep 28, '05 03:53:37PM

You know that you can just change the library location in iTunes' preferences and then tell iTunes to organize your files. Voila, everything is copied to the new location.

Or is this doing something else?



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: DeltaTee on Sep 29, '05 04:03:37AM

This script will allow you to not have to move the entire library to a different disk. So that you can keep most of the library on your laptop hard drive, but move some of the files to the larger desktop drive which will only be accessible when at home.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: gazinda on Oct 18, '05 02:17:44PM

I have been messing with this for sometime and I finally succeeded, I exported the library to my external hard drive. Then I deleted the iTunes library from my C drive (but I did not empty the recycle bin until I was sure I had it right) Then I opened iTunes and it was empty so I hit import library and selected it from my eternal hard drive file and there it was. I believe somewhere in the process I may have changed the preferences also. Once I made sure every single song was there I emptied the recycle bin and it was done!!!



[ Reply to This | # ]
folder aliases work with iTunes
Authored by: ratthing on Sep 28, '05 04:05:35PM

I just dragged the iTunes Music folder someplace else (leaving the library files in place, since they are small), then made an alias of the relocated iTunes Music folder in the original iTunes folder. I attempted to use a UNIX-style link (e.g. ln -s), but iTunes didn't like that.

I think the preference change is probably the better idea, though, unless you want to span multiple locations. You could do that with folder aliases per artist within the iTunes Music folder--that would be kind of ugly, though.

=RT=



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: xianman on Sep 28, '05 04:21:43PM

How I long for the day when I can have multiple libraries in iTunes. I would be so delighted if I could simply keep my favorites on my internal laptop hard drive so they would always be with me. Then when I get home and plug in an external hard drive another library would show up in my iTunes list, as if I simply plugged in an iPod.

This would be such an easy, elegant, Apple-like solution, and I have written Apple a number of times with it. Why are we at iTunes 5.0 and this feature is still not there? What am I missing?

I just had a strange passing thought. Could it be possible to fake an iPod with a disc image? That way you could have say a 60GB disc image on an external drive that when mounted would show up in iTunes as an iPod. I suspect this wouldn't work for one reason or another, although perhaps some enterprising hacker could whip up some kind of iPod emulator.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: DougAdams on Sep 28, '05 05:32:24PM
Could it be possible to fake an iPod with a disc image?

No, because it's not an iPod and iTunes won't recognize anything but an iPod as an iPod. I know that sounds obvious, but it was a good thought.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Move iTunes audio files between hard drives via script
Authored by: Kimhill on Sep 29, '05 06:23:37AM
"I would be so delighted if I could simply keep my favorites on my internal laptop hard drive so they would always be with me."

What we really need is a transparent way to keep a subset of the main library on the laptop. The best way, I think, would be the ability to specify that certain playlists are stored on the internal HD. I don't believe there is any good scripting solution to this problem -- Apple would have to help.

[ Reply to This | # ]

Move iTunes audio files between hard drives via script
Authored by: ratthing on Oct 02, '05 08:00:02AM

That's a really good idea. Treat the laptop similarly to the iPod. The only real issue I can see is, how are you going to push the updates to the laptop? Over the network would be pretty slow (well, I guess compared to my USB 1.0 to my iPod via the Quicksilver, it might be a bit of an improvement :-).

In any case you should submit that to Apple. There is some precendence for this approach--MSft's licensing of Office now acknowledges you may install it on desktop & laptop.

=RT=



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: Kimhill on Oct 03, '05 08:21:05AM

"how are you going to push the updates to the laptop?"

For me, as for many out there, the laptop is the main computer. So updating both locations is no problem. iTunes would know that it has to replicate certain playlists to two locations.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: cougar718 on Sep 28, '05 07:05:50PM
I, like others wondered what this script was doing at first. We all know you can not move files from 1 drive to another without copying them first. You can however "move" then delete the source files automatically - Although this may be dangerous.
But none the less, in the scenario that was given, the point was that the internal drive could not hold any more music and "new" music had to be stored on a second hardrive. Assuming this, iTunes library is being changed via AppleScript to reference the different locations of the music. Consequently, this means the music is not consolidated.
I consider myself an AppleScript expert but I believe this is what this script is accomplishing. The original poster did not make it clear what exactly this script is doing.

---
Rick alias cougar

[ Reply to This | # ]

Move iTunes audio files between hard drives via script
Authored by: mnb on Sep 29, '05 01:07:16PM

Script? why bother?

Make a folder on the destination drive. I named mine iTunes.
Open iTunes. Open the prefs and point iTunes to the new folder you just created for where your music is.

NOTE: If this disk is offline, any music imported will go to the default location: ~/Music/iTunes/ But once back online, you can use the Consolidate Library feature to clean up. Very handy!

Now quit iTunes.
go to ~/Music/iTunes

Move the iTunes Music folder from there to the new drive's iTunes Folder you created. The path should be:

drive/iTunes/iTunes Music/

You can bury the iTunes folder if you want, just make sure iTunes Music is dropped on iTunes.

Relaunch iTunes

Voila! You're done. If copied your music when doing the move (not a bad idea, actually), simply rename the old iTunes Music Folder before launching iTunes. Then play any song. If it works, you did everything right. If it doesn't you probably didn't point it to the right directory or you didn't move the iTunes Music folder to the right directory.

You need only move the iTunes Music folder (which contains folders full of MP3s, etc). You don't have to worry about the iTunes Library files, those are ALWAYS kept in ~/Music/iTunes.






[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: DougAdams on Sep 29, '05 02:26:54PM
Remember to only move/copy the folder containing audio files. Leave any other files in ~/Music/iTunes where they are, including the XML file and any "Library"-named files. iTunes expects these files to be in ~/Music/iTunes. Also, do not alias the ~/Music/iTunes folder elsewhere. The files in it aren't that large and your home folder won't suffer. Be sure your "designated" Music folder (the one with audio files in it, not ~/Music) is set in Preferences. This folder can be anywhere, just be sure to tell iTunes where it is.

---
Doug's AppleScripts for iTunes
http://www.dougscripts.com/itunes/

[ Reply to This | # ]

Move iTunes audio files between hard drives via script
Authored by: loren_ryter on Oct 01, '05 09:16:23AM

this method assumes that you have one music folder. if you have more than one, a script like this could come in handy -- but i need to look at it first. so far I can't even compile it. (see reply in main thread).



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: sjk on Sep 29, '05 08:55:14PM

Partly in response to Kimhill's post, here's a way to keep a subset of the iTunes library on your laptop drive:

• Set the "iTunes Music folder location" preference to a folder on a volume of your internal drive, like the default ~/Music/iTunes/iTunes Music folder.

Then:

• Check the "Copy files to iTunes Music folder when adding to library" preference when you want to add content to the library that'll be saved in the iTunes Music folder. iTMS purchases are automatically saved there regardless of the preference setting.

• Uncheck the "Copy files to iTunes Music folder when adding to library" preference when you want to add content to the library from folders on different volumes.

Or:

• Leave "Copy files to iTunes Music folder when adding to library" unchecked, store content for iTunes in manually managed folders, and add those folders to the iTunes library.

In other words, the iTunes library might access different music folders on different volumes and can be influenced by the "Copy files to iTunes Music folder when adding to library" preference. I normally leave that pref unchecked and temporarily toggle it on when I specifically want content added to an iTunes-managed music folder (wherever it may be).

All of that may be obvious to this audience, but when people talk about the iTunes library it's not always clear if they mean the actual library and/or one or more music folders it's accessing. That differentiation can be important.

Multiple iTunes libraries aren't nearly as important for me as ways to manage different music folders for a single library directly from iTunes. And I think that's what some (not all!) people really mean when they talk about wanting multiple iTunes libraries.

It could take another lengthy post to address some "yeah, I know all that, but ..." reactions to this post but I'll just keep it simple by admitting that iTunes still begs for more flexibility in its library/folder management. :-)



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: zzmcclos on Sep 30, '05 09:24:20AM

I skimmed the above comments, and now here's my humble (ahem) solution for "getting" music from one iTunes library to another; pseudo-code for general solution follows. If and when someone automates these steps, please provide the script for all to enjoy. Thanks...

1. Create a playlist with the music to copy/move in the source iTunes library, say toGet;

2. Right click on the toGet playlist, and "Export Song List..." to an .xml file, toGet.xml;

3. Copy toGet.xml to the target machine, and now work from there i.e. I'm now sitting at the machine where I'm copying/moving the files to;

4. Network mount the drive where the source library resides - this will cause the source iTunes library to be visible in: /Volumes/mntPoint/myUID/Music. My local iTunes library (the target) is /Users/myUID/Music;

5. Modify toGet.xml with one global search and replace as follows:

Globally seach for

localhost/Users

and replace it with

localhost/Volumes/mntPoint/Users

6. From the current/target iTunes library, File --> Import... the modified playlist, toGet.xml

After some network activity, all the music will have been copied to the target iTunes library!

7. (optional) To make this a move, goto the other iTunes library, and delete the songs.

Wah lah!

Enjoy. (-:



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: sjk on Oct 01, '05 09:26:28PM

I wonder if it'll ever be possible to do that kind of iTunes library/content management without manually modifying XML files or use external scripts.

Conspiracy says Apple's being conservative with iTunes features now to get more people to have reasons to buy the more feature-rich Pro version they've been secretly developing. :-)



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: zzmcclos on Oct 03, '05 04:35:09AM

I think Apple makes this kind of iTunes library management obscur to preservse the perception that Apple doesn't promote illegal music dissemination. Allowing the movement of copyrighted material freely between arbitrary libraries walks a fine line...



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: frickster on Oct 02, '05 02:33:37PM

This seems a bit much. I have three hard drives for music: one external, two internal. In my /user/<me/iTunes/iTunes Music folder I have two simlinks, one for the external FW drive and one for the secondary internal drive.

All of my music sits on either the firewire or secondary drives. New music imported goes to the primary drive, and then I manually sort it because I'm ridiculously picky about how my music is organized.

All you have to do is add the songs to iTunes from the location in which they're likely going to reside, and the files should be located just fine.

Or am I missing the point??

---
-frick



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: sjk on Oct 04, '05 07:43:36PM
I don't understand why you're manually sorting music folders after you've imported it. Why not just unset the "Copy files to iTunes Music folder when adding to library" preference before importing your preorganized music folders? Do you leave the "Keep iTunes Music folder organized" pref unset?

[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: loren_ryter on Oct 01, '05 09:21:30AM

if iTunes then tries to play a track on an external volume when it's not connected you'll wind up with a dead track. However I do think that iTunes has been fixed so that next time you mount that drive, iTunes will recognize it properly. I'm not sure, however, whether iTunes will skip that "dead track" in a normal playlist shuffle unless you try to play it manually. If it doesn't that could be a limitation of this method.

Personally, I keep two separate iTunes libraries -- one for laptop and one for external + laptop. and switch as needed. Doug's iTunes Library Manager does a fine job of this -- but I find it just as easy to do manually.



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: sjk on Oct 01, '05 08:55:06PM

Thanks for the info about dead tracks. I finally got around to ridding my main iTunes library of the few dozen remaining ones. I considered using Doug's "Bring Out Yer Dead" script but that would have modified Date Added info and I wanted to preserve it so I just reassociated the tracks directly from iTunes. I'll be surprised if any go dead again since all the files/folders for that iTunes library are now on permanently mounted internal volumes, with backups on external volumes and iTMS purchases redundantly burned to DVD. A few years of chaotically managed iTunes content are finally behind me.



[ Reply to This | # ]
iTunes Music library vs. music folder(s)
Authored by: zzmcclos on Oct 03, '05 11:19:29AM

Actually, when "File -> Import..." is used on an XML file (as specified above), iTunes copies the XML and the audio content (AIFF, WAV, ...) into the library from the source specified in the XML. When the source volume is unmounted, it doesn't matter - the content is now IN the target iTunes library. Hence, no dead track when the volume is unmounted.

I am, of course, assuming that "Copy files to iTunes Music folder when adding to library" has been specified in iTune's advanced preferences. That is why the song may be deleted from the source library - as in (optional) step 7.

Bill



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: loren_ryter on Oct 01, '05 09:13:43AM

Could you please post a link to a compiled script? Copying and pasting the contents of the linked web page will not compile in Script Editor.



[ Reply to This | # ]
Groovy Movin - notes from the originator
Authored by: Oliver on Oct 20, '05 04:27:55AM

Dear All,

this is Oliver, the originator of the code discussed above.

Sorry for delay in my response, I've been away on holiday. Now back on my desk.

First of all, the code you get when clicking "wrote my own script" does not compile (at least not at my machine). It seems some characters didn's copy over properly (e.g. the unequal sign). I'll get to Rob on this one.

Secondly, I am not sure I understood everything right in the comments submitted. The idea of the script is to allow you to move over some SELECTED tracks, not the entire library to another HD.
All you have to do is to provide a playlist (can be smart) and two folder locations. Groovy Movin' will then move (not copy!) every track that is in the playlist AND that is currently within the first folder to the second folder. It does so by copying the audio file to the new location, deleting the original and then (by pretending the users strikes some key combinations) select the offline track, hit apple+i (for info) confirm the reconnect prompt and relink the track to the dislocated audio file. Addmitedly this is a hideous approach and takes ages, because it is going through onr track after the other. (Groovy Movin manages about 300 tracks every hour!). However it keeps your ratings, comments, date added etc. intact as well as the folder structure of the audio files.
You can - if you set the internal properties - have Groovy Movin add one of two text strings - depending on whether the track's file now resides on the internal or the external drive - to either the comment, the desription or the category of the track. A Smart playlist then can filter all the tracks that are on the internal HD.
No, the iTunes library - that is the xml-file is not tampered with directly (I tried that, but found it to be too complicated)! All Groovy Movin does is to move the audio file and then hit iTunes with key combinations to relink the now offline track to the copied file, like a user would do. One by one. In an endless row. iTunes then updated itself by itself.
(All this info is included in a "users manual" incorporated in the script.)

The sript works (nearly) absolutely smooth on my setup and is fitted with some quite extended error handling. It does me a great job, day after day.
(Please note: If for some bizarre reason you got the script to work anyway, please note there is a silly syntax mistake in an error handling routine (you might not have encountered it yet...): Find "& TextOfTrackDetails" and replace it with "& my TextOfTrackDetails")


I am currently working on an update of the script. It's nearly finished and in testing mode. I'll make it available as soon as it's ready. Should take a week or two. Check this place.

Greetings to you all.

Oliver.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: Oliver on Oct 26, '05 09:32:59AM

This is Oliver again.

I have sent Rob an update of my script. I hope he'll make it available soon.

Again, the code you get when clicking "wrote my own" on my original comment doesn't compile, because some special characters got lost on the way. I hope this time it'll work.

All the best,

Oliver.



[ Reply to This | # ]
Move iTunes audio files between hard drives via script
Authored by: Oliver on Nov 01, '05 10:17:38AM

Me again.

Rob has updated the link on my initial hint. It's a zip containing 3 files of which you actually only need the script file.
I downloaded it and it compiled well.

Tell me if it works for you.

Greetings,


Oliver



[ Reply to This | # ]