Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use Folder Actions to implement OS 9 folder auto-sorting System
Back in OS 9, if you dropped a new file (extension/font/control panel etc..) on the Sytem Folder it would offer to auto-sort the file to the correct sub-directory based on the type of file. In Mac OS X, system assets and extensions are put in the Library directories. These directories do not auto-sort dropped files into the correct subdirectory.

With Jaguar's AppleScript Folder Actions, however, you can get your libraries to auto-sort some of the file-types that live there. All you have to do is enable Folder Actions (done through the AppleScript Menu Extra in Applications -> AppleScript -> script menu.menu). Then attach the script I wrote to your Library(s)

This script cannot auto-sort all filetypes - but can handle the following types:

  • prefpanes
  • screensavers
  • trueType fonts
  • services
  • Compiled AppleScripts
  • Frameworks
  • Scripting Additions
  • AIFF sounds.
Enjoy! PS just in case my mac.com page gets overloaded, the script is in the second part of the hint, too.

The script (robg adds: Any formatting errors are mine, introduced when trying to narrow the display width a bit)
property SaverRecord : 
  {extension:"saver", description:"Screen Saver", directory:"Screen Savers"}     
property prefpaneRecord : 
  {extension:"prefpane", description:"System Preference Pane", directory:"preferencePanes"}
property scriptRecord : 
  {extension:"scpt", description:"Compiled AppleScript", directory:"scripts"}
property serviceRecord : 
  {extension:"service", description:"System Service", directory:"services"}
property frameworkRecord : 
  {extension:"framework", description:"Framework", directory:"frameworks"}
property scriptingAdditionRecord : 
  {extension:"osax", description:"Scripting Addition", directory:"ScriptingAdditions"}
property aiffSoundRecord : 
  {extension:"aiff", description:"Macintosh Sound", directory:"Sounds"}
property ttfFontRecord : 
  {extension:"ttf", description:"TrueType Font", directory:"Fonts"}
property dFontRecord : 
  {extension:"dfont", description:"dFont", directory:"Fonts"}
property otfFontRecord : 
  {extension:"otf", description:"otFont", directory:"Fonts"}
property validRecords : 
  {SaverRecord, prefpaneRecord, scriptRecord, serviceRecord, frameworkRecord, 
    scriptingAdditionRecord, aiffSoundRecord, ttfFontRecord, dFontRecord, otfFontRecord}

--The handler for responding to when items are added to a folder: 
on adding folder items to targetFolder after receiving droppedItems
  
  -- set targetFolderAlias to targetFolder as alias
  repeat with currentFile in droppedItems
    
    tell application "Finder"
      set targetFolderName to the name of targetFolder
      set droppedFileName to the name of currentFile
      set droppedFileInfo to info for currentFile
    end tell
    
    repeat with currentRecord in validRecords
      if extension of currentRecord is equal to the 
        name extension of droppedFileInfo then
        
        tell application "Finder"
          set newTargetFolder to (folder named 
            (directory of currentRecord) of targetFolder)
          -- not sure about validity of next line... 
          if newTargetFolder exists then
            move currentFile to newTargetFolder
            display dialog " " & targetFolderName & 
              " has auto-sorted a " & description of currentRecord 
              & "." buttons {"?"} default button 1 
              giving up after 3 --seconds 
          else
            display dialog 
              "the folder isn't there!" buttons {"OK"}
          end if
        end tell
        
      end if
    end repeat
    
  end repeat
end adding folder items to
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,502 views]  

Use Folder Actions to implement OS 9 folder auto-sorting | 13 comments | Create New Account
Click here to return to the 'Use Folder Actions to implement OS 9 folder auto-sorting' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: displaced on May 23, '03 10:15:22AM

Not downloaded yet (I'm currently wrestling with a Debian Linux box) but that looks pretty cool, thanks!

Folder Action scripts have helped me out occasionally. For example, my scanner software couldn't Scan & Print - the print job always crashed the print queue. Instead, I set up a Scan & Print 'drop box', with a FA Script attached to automatically open new items in Preview, then use a bit of GUI Scripting to make Preview print the image...



[ Reply to This | # ]
Now with Easy Install!
Authored by: Diggory on May 23, '03 10:48:24AM
Hi, just to update:

I have written another applescript to make the install process easier.

See here

If you have the Script Editor 2 beta you can install straight from the web page.

---
*****
Use MoreInternet Preference Pane to change Internet Helpers without IE

[ Reply to This | # ]

Now with Easy Install!
Authored by: kconboy on May 23, '03 12:32:21PM

Thanks, guys. You rock!

---
----
kev



[ Reply to This | # ]
Keynote Themes
Authored by: vgz on May 23, '03 06:30:15PM
Add the following line to the begining of the script:
property kthRecord : {extension:"kth", «class dscr»:"Keynote Theme", directory:"Application Support:Keynote:Themes"}
Also add kthRecord to the following line as shown:
property validRecords : {SaverRecord, prefpaneRecord, scriptRecord, serviceRecord, frameworkRecord, scriptingAdditionRecord, aiffSoundRecord, ttfFontRecord, dFontRecord, otfFontRecord, kthRecord}
This will add Keynote Theme sorting to the script.

---
VGZ:
Otaku, Fanfic author, and Mac Fanatic

[ Reply to This | # ]

updated script
Authored by: Diggory on May 24, '03 09:14:05AM
I've updated the script to include VGZ's Keynote Theme support - and also ColorSync Profiles.

See the web page for an updated version of the script: http//www.monkeyfood.com/software/LibrarySorter/

---
*****
Use MoreInternet Preference Pane to change Internet Helpers without IE

[ Reply to This | # ]

gah! URL mistake
Authored by: Diggory on May 24, '03 09:16:18AM
I got the url wrong on that last link (the text is correct - but the link fails)

try this new one

---
*****
Use MoreInternet Preference Pane to change Internet Helpers without IE

[ Reply to This | # ]

Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: ewelch on May 26, '03 12:36:43AM

I'm in the process of reading the new book (just released this month), "Teach Yourself Applescript in 24 hours" by Sams, and I noticed in the Finder dictionary that there's an entry dealing with "autorouting."

[routing suppressed boolean] -- Specifies whether or not to autoroute items (default is false). Only applies when moving to the system folder.

Isn't this a way of coercing routing to occur? Or am I not understading what routing is?

It specifically seems to be saying something about what can heppen when a file is moved to the system folder. This is not in the legacy section of the dictionary. It's in the events section of the standard suite.

BTW, the book is great for an Applescript newbie like me! It's about time someone wrote a good, understandable book on Applescript.

Now, who's going to write the book on Applescripting Photoshop?

---
Eric

Ernest Hemingway's writing reminds me of the farting of an old horse. - E.B. White



[ Reply to This | # ]
Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: Diggory on May 26, '03 06:24:35AM
Yes - I saw this too - however this refers to the OS 9 system folder - I'm 99% sure that Mac OS X can not autoroute.

---
*****
Use MoreInternet Preference Pane to change Internet Helpers without IE

[ Reply to This | # ]

Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: ckier on May 26, '03 09:07:57AM

Is there a way to modify this script so that it displays the confirmation with SEC Helper instead of using a Finder dialog.



[ Reply to This | # ]
Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: Diggory on May 27, '03 10:19:16AM
What is SEC helper?

---
*****
Use MoreInternet Preference Pane to change Internet Helpers without IE

[ Reply to This | # ]

Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: Diggory on May 27, '03 06:20:18PM
yes - replace instances of Display Dialog "foo" with

tell application "SEC Helper"
show screen message "Foo"
end tell

---
*****
Use MoreInternet Preference Pane to change Internet Helpers without IE

[ Reply to This | # ]

Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: BigJoeH on May 26, '03 01:52:26PM

I found this great app called Alfred that does just what you want and more, you can turn on and off prefpanes. It can be found at http://www.inferiis.com/products/alfred. I found this very usefull since I came to MacOSX from Sys 9



[ Reply to This | # ]
Use Folder Actions to implement OS 9 folder auto-sorting
Authored by: DanFrakes on May 27, '03 08:27:12PM

I was just going to recommend Alfred, as well. It's an excellent utility that not only auto-routes all of the common files you would encounter, but also lets you create custom "rules" for other types of files. For example, you can create a rule that places any .mov file in your Movies folder, or any .mp3 file in your iTunes Music Folder.

---
------------------------------------------
Mac OS X Power Tools:
http://www.macosxpowertools.com/



[ Reply to This | # ]