-- This Folder Action Script should be attached to /Users/Shared/Faxes/ -- It will rename incoming faxes to give them unique names of the form: -- "Received Fax on [date & time] from [CallerID].pdf" -- Written by Diggory Laycock (http://www.monkeyfood.com) property FaxFilenameprefix : "FAX " property FaxFilenameNewPrefix : "Received " -- subroutine to replace chars in a string on replace_chars(this_text, search_string, replacement_string) set AppleScript's text item delimiters to the search_string set the item_list to every text item of this_text set AppleScript's text item delimiters to the replacement_string set this_text to the item_list as string set AppleScript's text item delimiters to "" return this_text end replace_chars -- Folder Action stuff on adding folder items to targetFolder after receiving DroppedItems repeat with currentFile in DroppedItems tell application "Finder" set droppedFileName to the name of currentFile set droppedFileInfo to info for currentFile if droppedFileName starts with FaxFilenameprefix then -- rename the file -- get the callerID and file extension of the new file copy (characters (count of FaxFilenameprefix) thru (count of characters of droppedFileName) of droppedFileName) to callerIDAndExtension -- Get the date & time as a string set now to current date set dateStampString to (date string of now & " - " & time string of now) as string -- If you want an American style date format (YYYY-MM-DD) then uncomment the line below: -- set dateStampString to (year of now & "-" & (month of now as integer) & "-" & (day of now) & " - " & time string of now) as string -- We have to alter the start of the filename -- otherwise the file will appear to be a new file - and this script will run again causing an infinite loop. set newFaxFileName to (FaxFilenameNewPrefix & FaxFilenameprefix & "on " & dateStampString & callerIDAndExtension) as string -- Times have colons in - which is a no-no in filenames. set newFaxFileName to my replace_chars(newFaxFileName, ":", ";") -- Rename the actual file set the name of currentFile to newFaxFileName end if end tell end repeat end adding folder items to