Need AppleScript to "add tracks" from xml-file to music app (including date/time change and edit track-infos)

Hi,

as I decided to completely move everything from windows to OSX I finally want to transfer my iTunes Windows Library to OSX Music App.


As I really spent a lot of time in organizing and building my database, I have to keep all data - including the non taggable ones :)


I searched a lot and know basic options to transfer, BUT:

My music files are well organized and located outside the iTunes user folder. All files are well tagged (aif-files). As I build my windows library for years and very carefully, I HAVE to keep the track date added infos.

I know changing system date/time is not a smart programing way.... but as far as I know, the only option to meet my goal in this case:)


####


The script-goal would be:


# OPEN my individual exported XML-File (sample file enclosed)

# Read each entry through the end


# Read File entry, example: 

<FILE>S:\SOUNDPOOL\ALBUMS\VARIOUS ARTISTS\(AHK-TOONG BAY-BI) COVERED [2011]\NINE INCH NAILS - Zoo Station [2011#01].AIF</FILE>


Change (old) windows base folder: "S:\SOUNDPOOL\“ to (new) osx folder: "file:///Volumes/_KOPIFLIX_EXT/_MEDIA/SOUNDPOOL/


# Read other "additional" variables for this entry:


<GROUPING>Rock</GROUPING>

<COMPILATION>1</COMPILATION>


<DATEADDED>2011-02-01T00:22:04</DATEADDED>

<LASTPLAYED>2012-01-13T09:43:16</LASTPLAYED>

<RATING>0</RATING>

<PLAYEDCOUNT>5</PLAYEDCOUNT>


# Launch Music App (if not already open)

# Change OSX date/time to read variable DATEADDED, example: 2011-02-01T00:22:04

# Add Audio-File to Music Library.


# Write/Set the corresponding variables for this file (GROUPING,….PLAYEDCOUNT)

(all other infos are tagged properly and are imported through import/adding file)


# ? if necessary, close Music App

# ? if necessary, set osx date/time to current local time


# Read next file-entry from XML-File


# Loop til end of file


I really would appreciate help very much, thank you!


(sorry, I cannot add a file here - enclosed some sample text from my noted xml-file)


<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlnsd="urn:schemas-microsoft-comfficedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="T_ITUNES_EXPORT.xsd" generated="2024-03-02T15:21:28">
<T_ITUNES_EXPORT>
<FILE>S:\SOUNDPOOL\ALBUMS\VARIOUS ARTISTS\(AHK-TOONG BAY-BI) COVERED [2011]\NINE INCH NAILS - Zoo Station [2011#01].AIF</FILE>
<GROUPING></GROUPING>
<COMPILATION>1</COMPILATION>
<GAPLESS>0</GAPLESS>
<DATEADDED>2011-02-01T00:22:04</DATEADDED>
<LASTPLAYED>2012-01-13T09:43:16</LASTPLAYED>
<RATING>0</RATING>
<PLAYEDCOUNT>5</PLAYEDCOUNT>
</T_ITUNES_EXPORT>
<T_ITUNES_EXPORT>
<FILE>S:\SOUNDPOOL\ALBUMS\VARIOUS ARTISTS\(AHK-TOONG BAY-BI) COVERED [2011]\KILLERS, THE - Ultra Violet (Light My Way) [2011#10].AIF</FILE>
<GROUPING></GROUPING>
<COMPILATION>1</COMPILATION>
<GAPLESS>0</GAPLESS>
<DATEADDED>2011-02-01T01:53:30</DATEADDED>
<LASTPLAYED>2011-11-07T02:16:33</LASTPLAYED>
<RATING>0</RATING>
<PLAYEDCOUNT>2</PLAYEDCOUNT>
</T_ITUNES_EXPORT>
<T_ITUNES_EXPORT>
<FILE>S:\SOUNDPOOL\ALBUMS\VARIOUS ARTISTS\(AHK-TOONG BAY-BI) COVERED [2011]\GLASVEGAS - Acrobat [2011#11].AIF</FILE>
<GROUPING></GROUPING>
<COMPILATION>1</COMPILATION>
<GAPLESS>0</GAPLESS>
<DATEADDED>2011-02-01T01:35:07</DATEADDED>
<LASTPLAYED>2011-11-07T02:20:42</LASTPLAYED>
<RATING>0</RATING>
<PLAYEDCOUNT>2</PLAYEDCOUNT>
</T_ITUNES_EXPORT>


I'm on OSX Ventura 13.6.4, Music App Version 1.3.6.14

Mac Studio (2023)

Posted on Mar 8, 2024 2:12 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 11, 2024 4:21 AM

well tt2, what should I say?

Thank you so much for insisting in trying the itl-file again, basically it worked! I can't say how happy I am:)


(obviously apple changed the file look-up mode, last time I tried (some months ago) it didn't work with "relocating". And importing an xml-library never worked, because only "found" files are imported, and if the folder location differs, which is the fact from windows to osx, nothing will be imported.)


For others, the way it worked:


Copy .itl file (windows iTunes 12.6.5.3) to osx.

Launch Music App (1.3.6.14) with pressed option-key.

Select the iTunes Library.itl file.

Music prompt's you for selecting a folder/library name for the new library.

New library is build.


Try to playback one audio file. (Error, because file location changed)

Select the "new" location for this file.

Music asks for searching all missing files based on the new location. This needs some time.

Success.

All files relocated correct.


All "windows saved and not tagged" media library fields (example: rating, date added, last played) imported correct.

This made my day!



One more thing:

Hopefully easy to "repair"

The cover art's are not shown.

If I right-click a file, and select cover, nothing is shown.

I can verify that the cover is embedded correct in the aif-files. Cross check: If I add the sample file to a new music library the cover is shown immediately.


Any way to "rebuild" or refresh the artwork?

It seems that the /Users/PCAnder/Library/Containers/com.apple.AMPArtworkAgent/Data/Documents/artwork folder is not updated.


Additional info: As I kind of share my library (no use or opened at the same time) with my mac-studio and my macbook-air, I store my music lib on a one drive folder (not under the default "Music" folder location.)


Thx for further ideas;)

Similar questions

3 replies
Question marked as Top-ranking reply

Mar 11, 2024 4:21 AM in response to turingtest2

well tt2, what should I say?

Thank you so much for insisting in trying the itl-file again, basically it worked! I can't say how happy I am:)


(obviously apple changed the file look-up mode, last time I tried (some months ago) it didn't work with "relocating". And importing an xml-library never worked, because only "found" files are imported, and if the folder location differs, which is the fact from windows to osx, nothing will be imported.)


For others, the way it worked:


Copy .itl file (windows iTunes 12.6.5.3) to osx.

Launch Music App (1.3.6.14) with pressed option-key.

Select the iTunes Library.itl file.

Music prompt's you for selecting a folder/library name for the new library.

New library is build.


Try to playback one audio file. (Error, because file location changed)

Select the "new" location for this file.

Music asks for searching all missing files based on the new location. This needs some time.

Success.

All files relocated correct.


All "windows saved and not tagged" media library fields (example: rating, date added, last played) imported correct.

This made my day!



One more thing:

Hopefully easy to "repair"

The cover art's are not shown.

If I right-click a file, and select cover, nothing is shown.

I can verify that the cover is embedded correct in the aif-files. Cross check: If I add the sample file to a new music library the cover is shown immediately.


Any way to "rebuild" or refresh the artwork?

It seems that the /Users/PCAnder/Library/Containers/com.apple.AMPArtworkAgent/Data/Documents/artwork folder is not updated.


Additional info: As I kind of share my library (no use or opened at the same time) with my mac-studio and my macbook-air, I store my music lib on a one drive folder (not under the default "Music" folder location.)


Thx for further ideas;)

Mar 11, 2024 4:22 PM in response to PCAnder

You could try removing the artwork cache which should force Music to rebuild it. The location should be ~/Library/Containers/com.apple.AMPArtworkAgent/Data/Documents where ~ is your user's home folder.


Show hidden files and folders with Shift+Cmd+. to aid your navigation.



See also Managing your Mac media libraries - Apple Community for post iTunes to Music migration advice.



tt2


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Need AppleScript to "add tracks" from xml-file to music app (including date/time change and edit track-infos)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.