Tech198

Q: sorting in itunes

Is it possible to export the sorting info for movies in itunes and re-import them into another playlist ?

 

a.k.a in one playlist i have say

 

"The Lord of the Rings"

sort as "Lord of the Rings"

 

Can i export this info in CSV or something ? That way i can create new playlist,,, import all my movies and run a script or automatically reapply the sorting to all movies at once.

 

If not possible between .it files alone, then could be done inside itunes ?

 

e.g i was thinking user is asked to open first .it file... Apple script grabs all "Sort as" info, stored them as variables, closes the file. User is asked to open second .it file and Apple script import sort info back.

MacBook Pro with Retina display, OS X Yosemite (10.10.5), null

Posted on Aug 14, 2016 4:24 PM

Close

Q: sorting in itunes

  • All replies
  • Helpful answers

  • by SGIII,

    SGIII SGIII Aug 14, 2016 5:35 PM in response to Tech198
    Level 6 (10,637 points)
    Mac OS X
    Aug 14, 2016 5:35 PM in response to Tech198

    Have you had a look at the resources available here?

     

    SG

  • by Camelot,

    Camelot Camelot Aug 15, 2016 1:55 PM in response to Tech198
    Level 8 (47,243 points)
    Mac OS X
    Aug 15, 2016 1:55 PM in response to Tech198

    It's pretty trivial to export a list of movie names with their sort name:

     

    use AppleScript version "2.4" -- Yosemite (10.10) or later

    use scripting additions

     

    tell application "iTunes"

      set f to open for access file ((path to desktop as text) & "tracks.txt") with write permission

      set eof f to 0

      set myMovies to (get every track whose media kind is movie)

      repeat with aTrack in myMovies

      tell aTrack

      write its name & "," & its sort name & return to f

      end tell

      end repeat

      close access f

    end tell


    However, I'm unsure as to the goal you're asking for - are you suggesting that the same track in two playlists may have different sorting values? I've never noticed that if that's the case (I've always assumed the sort name is associated with the track and not with the specific track/playlist combination).

     

    In either case, resetting the sort values is a matter of reversing the process - read the file, find the track based on the first field, set the sort value to the second field. However I would caution against using CSV since movie names could, conceivable, contain a comma, which could interfere with reading the data back in. Use some other delimiter.