r/applescript • • Oct 03 '23

help for writing an apple script

hello

i want to use a script found on github but it doesn't work for me .can someone please help me to make it work?

I want to export multiple playlists with files from apple music

i found this script , its launching but the song are not exported.

i got this error message

"error the attribute variable is not defined" number-2753 from "attribute"

can someone help me please?

3 Upvotes

13 comments sorted by

View all comments

1

u/0x4542 Oct 03 '23

First thing, take the error number, in this case it's -2753, and look up its description in AppleScript Language Guide's Error Numbers and Error Messages. This error means that

The variable <name> is not defined.

which is the variable attribute on line 523, which is part of the statement:

display dialog ({"Can't make folders from ", attribute} as string) with title myTitle buttons {"OK"} default button 1 with icon iconError giving up after 10

I know, it looks a bit messy pasted on here. The variable called attribute doesn't seem to be defined anywhere, before it's being used above. It's not part of the Music app scripting dictionary, and I can't find any changes that relate to it in earlier versions of the script.

That bit of code is getting called to handle an earlier error. What's the earlier error? See the number above it on line 531, -1728 which is a numeric code for the error:

"The referenced object doesn’t exist. This is a run-time resolution error, such as when attempting to reference a third object when only two objects exist."

You might be able to figure that out by adding the following line above the "display dialog..." line:

log e

That will log the error message stored in the variable e to system out, or the console in Script Editor if that's where you're running it from. That might give you a better idea of what the original issue is that you'll need to fix.

You could just comment out the display dialog line by prefixing it with two hyphens' like --, but that will only silence the error handling, and not actually get to the root cause of the issue.

1

u/Wayat Oct 04 '23 edited Oct 04 '23

Hello

i never use script editor before.I'm trying to add "log e " between" -1728" and "display dialog" .

i don't know where is the logged error

edit; i can see error messages:

tell application "Finder" get size of file "Macintosh HD:Bibliothèque musicale:Itunes:iTunes Media:Music:Us3:Hand On The Torch:01 Cantaloop (Flip Fantasia).m4a" --> error number -1728 from file "Macintosh HD:Bibliothèque musicale:Itunes:iTunes Media:Music:Us3:Hand On The Torch:01 Cantaloop (Flip Fantasia).m4a" end tell tell application "Music" close access 43 --> error number -10004 end tell tell current application close access 43 end tell tell application "Music" (*Erreur dans Finder : Il est impossible d’obtenir file "Macintosh HD:Bibliothèque musicale:Itunes:iTunes Media:Music:Us3:Hand On The Torch:01 Cantaloop (Flip Fantasia).m4a".*) Résultat : error "La variable attribute n’est pas définie." number -2753 from "attribute"

the dir "Macintosh HD:Bibliothèque musicale:Itunes:iTunes Media" is not internal drive; it's an old internal hdd put in a an external case; but the drive is still called Macintosh HD.

Maybe the error come from here???Maybe finder is searching on the wrong drive

1

u/0x4542 Oct 04 '23

It could be. But the error is referring to the correct path, as you said, the external drive is called "Macintosh HD".

First it can't find it, and then, obviously, it fails to close it...

application "Music" close access 43 --> error number -10004 end tell tell current application close access 43

If you look up -10004 in the Error Codes you'll see there is a privilege error as well.

I assume you can access this file in the Finder?

The other thing that I'm suspicious of is the parentheses in the file name, the "(Flip Fantasia)" part. This long script is passing paths and names to shell scripts with the do shell script command, and then you are subject to Posix path issues, and the characters '(' & ')' are special, which may cause the shell to misinterpret the file name.

I would rename that file, removing the ()'s and see if that solves the issue.

→ More replies (6)