iTunes music folder location?


I hope this question isn’t too stupid:

does anybody know how to (easily) retrieve the location of the iTunes music folder?

I know that I could parse the libraries .xml file, but i was hoping that there is an easier solution.

Thanks in advance for any help,
yours kodi

Your stuff is in your Home/Music/iTunes/iTunes Music folder

Hello Adam,

if I go to Preferences->Advanced->General and Change… my stuff might be in a different location :slight_smile:

My question was how to determine what a user chose as his prefered location.

Anyway, thanks for trying to help,
yours kodi

Hi kodi,

Try this:

tell application "iTunes"
	set lib_pl to first library playlist
	set item_ref to location of first track of lib_pl
end tell
set n to ""
repeat until n is "iTunes"
	tell application "Finder"
		set item_ref to (container of item_ref)
		set n to name of item_ref
	end tell
end repeat
return item_ref as alias

Only bad thing is iTunes needs to open.


Didn’t come up with much last time I saw this. Path to iTunes library

Hello kel,

thanks for your code snippet.
Its not returning the location of the iTunes Music folder in my case.
But your method is returning one of the folders where I store my music,
which is even better!

So thanks again for this nice idea.

Just in case somebody might be interested how to do the same in python with appscript:

def getMusicFolder():
libraryPlaylist = app(‘iTunes’).library_playlists.get()[0]
path = libraryPlaylist.tracks.get()[0].location.get().path
n = “”
while not n == “iTunes”:
path, n = os.path.split(path)
return path
except Exception, e:
print “[KRIX] unable to get music folder:”, e
return None

Thanks as well to Bruce for the forum link.
Have a nice day,
yours kodi