MACSCRPT Archives

September 2012

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Shane Stanley <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 29 Sep 2012 18:16:29 +1000
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
On 29/09/2012, at 5:14 PM, Cal <[log in to unmask]> wrote:

> From a ghost from the past...<mwa-ha-ha>

Oh, very spooky...
> 
> I've been stumped with a problem for a while.
> 
> I've got a massive iTunes library on an external HD, with the music files stored in various places within a folder hierarchy (not in the iTunes Media or Music folder)..  I've made a copy of everything onto another external HD with a different disk name. All I need to do is to get iTunes to point to the new drive, with the music files in the same places within the folder hierarchy.  I've been unsuccessful at getting iTunes to make the switch.  (I tried editing the library files with a hex editor and that's a bust.)
> 
> Someone suggested using AppleScript to do this.  A quick look at the dictionary doesn't suggest anything like:
> 
> set the disk of every file track whose disk is "aaa" to "bbb"
> 
> Any ideas?

<picking jaw up from floor...>

Maybe something like this:

tell application id "com.apple.iTunes" -- iTunes.app
	repeat with i from 1 to count of tracks of playlist 1
		set oldLocation to location of track i of playlist 1
		set newLocation to my modLocation(oldLocation)
		set location of track 1 of playlist 1 to newLocation
	end repeat
end tell

on modLocation(oldLocation)
	set oldPath to oldLocation as text
	set saveTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {":"}
	set oldPath to text from text item 2 to character -1 of oldPath
	set AppleScript's text item delimiters to saveTID
	log oldPath
	return alias (newDiskName & ":" & oldPath)
end modLocation

It assumes they're still in the old place as well, which might not be the case. But it might give you some ideas.


-- 
Shane Stanley <[log in to unmask]>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

ATOM RSS1 RSS2