Created
November 10, 2009 16:55
-
-
Save wesrog/231031 to your computer and use it in GitHub Desktop.
Sort iTunes groupings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def w(t); t.grouping = s(t) unless s?(t); end | |
def s?(t); t.grouping.to_s == s(t); end | |
def s(t); t.grouping.to_s.split(', ').sort.join(', '); end | |
require 'osx/cocoa' | |
OSX.require_framework 'ScriptingBridge' | |
a = OSX::SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") | |
l = a.sources.first.playlists.detect { |p| p.name == 'Library' } | |
l.tracks.each_with_index { |t,i| print "\r\e[0KProcessing: #{i}/#{l.tracks.size}"; w(t); $stdout.flush; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment