Totally override a folder's name sort order in the Finder

Jun 25, '03 10:08:00AM

Contributed by: Robert Black

Basically, this is a glorified example using AppleScript to illustrate a simple method to sort a Finder folder in a non-standard way. You can manually use this method to completely customise the sort order of a folder to override the normal sorting by name, date or kind, etc. The key to the trick is to use and sort by the comments field.

An Example: Tickle File

If anyone out there is as obsessed about organising yourself as I am, you've probably come across the concept of the Tickle File. A Tickle File is nothing more than a sequence of 12 folders (one for each month), and 31 more folders for the days of the month at the front. As each day of the month passes, you look inside the corresponding day folder, act on its contents, and then put the empty folder into the following month. This very simple structure allows you to effectively file things up to a year in advance, confident that they won't be overlooked.

Okay, here's the example - a way to use AppleScript to sort folders named after the months of the year, so that the current month is at the top, with the subsequent months in the correct order, and wrapping around for the start of the next year.

Each morning, when this AppleScript is run automatically by a third party macro tool, it opens my tickle file and makes sure that the sorting is up to date. I act on today's filed actions if there are any, and then drag today's now empty day folder down to the following month. When the next month starts, you look for any tasks/files dumped into the Month folder, and if there are some, sub-file them away in appropriate days of that month if you don't want to act on them immediately.

A stuffed archive of the basic folder structure is available here [thereafter.com.au].

Read the rest of the article for the script...

(If your system uses a language other than English, adjust the month names in both the script and folders accordingly)


property mypath : "Disk:GeneralReference:TickleFile:"
try
 tell application "Finder"
  open folder mypath
 end tell
on error
 set mypath to choose folder with prompt "Please select the folder ¬
 (named TickleFile?) containing the 12 folders with month names..."
 tell application "Finder"
  open folder mypath
 end tell
end try
set mymonths to {"January", "February", "March", "April", "May", "June", ¬
 "July", "August", "September", "October", "November", "December"}

-- Check that it's the right folder...
try
 repeat with n from 1 to 12
  set x to (mypath as string) & item n of mymonths as alias
 end repeat
on error
 display dialog "The TickleFile folder doesn't seem to contain the ¬
 correct 12 months. Stopping script." with icon stop buttons {"Okay"} ¬
  giving up after 10 default button 1
 return
end try

set curmonth to month of (current date) as string
set curmonthnum to monthnum(curmonth)

tell application "Finder"
 set current view of front window to list view
 set icon size of list view options of front window to small icon
 set visible of column comment column of list view options of front window to true
 set width of column comment column of list view options of front window to 0
 set sort column of list view options of front window to comment column
 repeat with n from 1 to 12
  set x to (mypath as string) & item n of mymonths
  set t to ((n - curmonthnum + 13) mod 12)
  if t = 0 then set t to 12
  set comment of item x to t as string
 end repeat
 activate
end tell

on monthnum(mymonth)
 set mymonths to {"January", "February", "March", "April", "May", "June", ¬
  "July", "August", "September", "October", "November", "December"}
 repeat with i from 1 to count of mymonths
  if mymonth = item i of mymonths then
   return i
  end if
 end repeat
end monthnum

Comments (19)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030624202400986