Fix iTunes / Music dead tracks with AppleScript

Hi,

For a few days, I have more than 5000 dead tracks in my Music library.

I'm a developer and I tried to fix the problem like I did before with an AppleScript library but here something strange happened.

Indeed, all my dead track are on my external hard drive but the location in Music begins with "file:///Volumes/" so Music can't read the files :

The correct path is the same without "file:///Volumes/" :

I though it will be easy to fix that but when I try to get the tracks location to trunk it, the value is missing.

So how can I fix that ?

Thx

Hi, How do you get the path data?

I got my selected file track on my Music.app by simple AppleScript.

tell application "Music"
	set aList to selection
	set aTrack to first item of aList
	location of aTrack
end tell

This script returns alias type data. AppleScript's native path format is alias.

Each file track has "location" property and it is not read only. It is change-able property.

http://piyocast.com/as/wp-content/uploads/2023/03/music_dict_part.png

So you will be able to select new location to each missing file tracks.

One track is a piece of cake. 5,000? Hmm...we have to take other approarch. We can write fixing AppleScript. But it requires remote checking and specification document....I will do that work on condition that I get paid for it.

Fix iTunes / Music dead tracks with AppleScript
 
 
Q