applescript: changes file location in iTunes

Posted:
in Genius Bar edited January 2014
Greetings. I have a large library of iTunes files that I would like to change to a new location. The files used to reside on a server, but I copied them to the local hard drive so I can listen to them when I am away from home. I've written up a script to get the location of one song in iTunes, change the location to the correct location, but I can't get iTunes to accept the change. Here is the script



Code:


tell application "iTunes"

set file_location to (location of track 1 of playlist 1) as string

end tell



set file_location to (replace_chars(file_location, "PUBLIC:mp3", "Macintosh HD:Music") as alias)



tell application "iTunes"

set location of track 1 of playlist 1 to file_location

end tell



on replace_chars(this_text, search_string, replacement_string)

set AppleScript's text item delimiters to the search_string

set the item_list to every text item of this_text

set AppleScript's text item delimiters to the replacement_string

set this_text to the item_list as string

set AppleScript's text item delimiters to ""

return this_text

end replace_chars







When I run this, it gives me "iTunes got an error: Unknown object type."



Any help would be appreciated.

Thanks,

Andrew
Sign In or Register to comment.