Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I dont understand why this is not working. If anybody knows how to resolve this issue:

tell application "iTunes"
  copy location of track 1 of playlist "Test" to Comments
end tell

Applescript does now show an error but when I see in iTunes, the "Comments" field is still empty.

Thanks!

share|improve this question
add comment

2 Answers

Because you copy the location to the Comments variable.

Here's how to put the location in the comment tag.

tell application "iTunes"
  tell track 1 of playlist "Test" to set comment to (its location as text)
  -- or set comment  of track 1 of playlist "Test" to (get location of track 1 of playlist "Test") as text
end tell
share|improve this answer
add comment

This should do the trick:

tell application "iTunes"
    set theLocation to location of track 1 of playlist "Test"
    set the comment of track 1 of playlist "Test" to POSIX path of theLocation as string
end tell

The as string is the key here, otherwise the types are incompatible.

If you want it as a one liner, you can do:

tell application "iTunes" to copy the POSIX path of (location of track 1 of playlist "Test" as string) to comment of track 1 of playlist "Test"

If you want the old Mac style paths with colons (Macintosh HD:Users:rob:Music) instead of Unix style (/Users/rob/Music), you can remove the POSIX path of parts of either of those.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.