AppleScript hacks 25-Aug-2010 2:43 PM
Edit FancyEdit New New Blog Upload All Recent Home Logout
Table Of Contents

Launching the Script Editor

I can never remember where the hell the script editor application is. So what I do is I create a document on my desktop named "whatever.scpt". Double-click it and it launches the script editor.

touch ~/Desktop/whatever.scpt
open ~/Desktop/whatever.scpt

Controlling screen gamma

Install Dark Adapted and then use the following applescript to set the gamma to something dark

tell application "DarkAdapted X"
    setGamma value "128,64,40"
end tell

The values are "Red, Green, Blue" from 0 to 255. Save this one out as an "Application" and drop it in your Dock.

Renumber tracks in iTunes

So you have a bunch of tracks in iTunes that don't have the correct track numbers or number of tracks in the disc. Save this out from script editor as a script, and drop it in your Library/iTunes/Scripts folder

tell application "iTunes"
  if selection is not {} then
    set selR to selection
    set sel to a reference to selR

    repeat with t from 1 to (length of selR)
      set theT to item t of sel
      if class of theT is file track then
          tell theT
            set track number to (t as number)
            set track count to ((length of selR) as number)
          end tell
        end try
      end if
    end repeat
  end if
end tell