Automator Plugin Script: Archive to...

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

Automator Plugin Script: Archive to... Wed Apr 09, 2008 1:18 pm • by alastor933
Here's the script for the Automator plugin I mentioned here.
It should work without modification, but you might want to read the thread at Apple discussions.
Install SpotMeta's CLI utility from its prefs window.
Set up the archiving attributes in SpotMeta before using the plugin.
As far as I can tell the plugin will set the attributes correctly without setting them up first, but SpotMeta will not show them, as they are not in its Definitions file.
There could be some confusion when you take a look in SpotMeta...

Code: Select all
   Archive to...
   script for an automator plugin
   uses SpotMeta <>
   some help from "red_menace" <>
   Actions in workflow:
   *  get Finder selection
   *  run script
   *  view results (does nothing, but read thread)
   *  move Finder selection   

on run {input, parameters}
   -- input:   a list of items received from the previous action
   -- output:   a list of items passed on to the next action
   set output to {} --to catch input
   set theCmd to "spotmeta set " -- talk to SpotMeta's CLI utility
   -- format date attribute, date = current date
   set dateAttr to "d:archiveDate='now' " -- say 'current date' to SpotMeta
   -- get archive category from user
   set archiveCategories to {"Archive", "Reference", "Software"}
   set archiveCategory to choose from list archiveCategories with prompt "Select one category:" with title "Archiving to..." without multiple selections allowed
   if archiveCategory is not false then -- user made selection
      set archiveAttr to "c:archiveCategory=" & archiveCategory-- format archiveCategory attribute
      set theCmd to theCmd & dateAttr & archiveAttr-- add attributes to cmd string
      repeat with anItem in input -- set attributes on passed items
         set end of output to (anItem as alias) -- workflow does not move files when script passes references
         set theCmd to theCmd & " " & quoted form of POSIX path of (anItem as alias) -- add filepath to cmd string
         do shell script theCmd -- set attributes
      end repeat
   else -- user pressed cancel
      set output to {} -- complete workflow without moving files
   end if
   return output
end run
Posts: 53
Joined: Wed Mar 05, 2008 3:52 pm
Location: Utrecht, Netherlands

Return to Tips & Tricks - DO NOT POST QUESTIONS