Hazel Script: reset archiveDate

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

Hazel Script: reset archiveDate Wed Apr 09, 2008 1:31 pm • by alastor933
This is the script for Hazel I discussed here:

Code: Select all
   script to reset archiveDate to lastUsedDate
   uses SpotMeta <http://www.fluffy.co.uk/spotmeta/>
   intended to be run by a Hazelrule

my hazelProcessFile(infile)

on hazelProcessFile(infile)
   -- make input usable
   set infile to quoted form of POSIX path of infile
   -- read lastUsedDate
   set lastUsedDate to do shell script "mdls -name kMDItemLastUsedDate " & infile
   -- isolate date/time string
   set tid to AppleScript's text item delimiters
   set AppleScript's text item delimiters to "= "
   set lastUsedDate to text item -1 of lastUsedDate
   set AppleScript's text item delimiters to tid
   set lastUsedDate to text 1 thru -7 of lastUsedDate
   -- reformat in SpotMeta date format YYYYMMDDHHMMSS (unspecified chars default to 19700101120000)
   -- just strip spaces and diacritics from lastUsedDate
   set archiveDate to (words of lastUsedDate) as string
   -- go reset archive date
   set theCmd to "spotmeta set d:archiveDate=" & archiveDate & " " & infile
   do shell script theCmd
end hazelProcessFile
Posts: 53
Joined: Wed Mar 05, 2008 3:52 pm
Location: Utrecht, Netherlands

Return to Tips & Tricks - DO NOT POST QUESTIONS