Pattern matching variables and Applescript

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Pattern matching variables and Applescript Mon Jun 29, 2015 6:28 am • by smackie
Hi,

I've got a problem trying to extract dates from filenames that is driving me slightly crazy. I have a bunch of document scans that have filenames that look like "Adobe - 10-10-13.pdf" or "CSAA - 10-21-13 54.pdf". The actual date of the document (extracted by OCR) is the mon-day-year format.

I have a simple date extraction rule that extracts the date from the filename to a variable called matchedDate. This does work as I can see the date showing up in matchedDate in the examine dialog for each file (and the correct rule is being matched). So I know the rule is working.

However, when I attempt to run a (very) simple Applescript, I get a stack overflow error.

2015-06-29 11:24:19.923 hazelworker[819] [Error] AppleScript failed: Error executing AppleScript on file /Users/smackie/Documents/Evernote/Set Creation Date/CSAA - 10-21-13 1.pdf.
2015-06-29 11:24:19.924 hazelworker[819] OSAScript error: {
NSLocalizedDescription = "Stack overflow.";
NSLocalizedFailureReason = "Stack overflow.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: null()>";
OSAScriptErrorBriefMessageKey = "Stack overflow.";
OSAScriptErrorMessageKey = "Stack overflow.";
OSAScriptErrorNumberKey = "-2706";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}

The only input attribute I'm passing to the script is the matchedDate custom variable. I'm sure this is something simple that I'm doing wrong but I can't see it. The Applescript looks like

on hazelProcessFile(theFile, inputAttributes)
tell "Finder"
set creation date of theFile to item 1 of inputAttributes
end tell
end hazelProcessFile

It doesn't matter whether the script is embedded or external in a file (with the full wrapping above). I still see stack overflows. The gotcha is that it *has* worked occasionally.

I'm running OS X 10.10.3 and Hazel 3.3.5

Any clues?

Scott...
smackie
 
Posts: 2
Joined: Tue Oct 29, 2013 1:32 pm

Have you tried the script outside of Hazel? Looking at it, I suspect an issue with Finder.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Indeed. After coming back to this fresh, I realized that I misread the example I'd been staring at and creation date is r/o in the Finder. Sigh. I guess I'm using a shell command...

Thanks for the reply

Scott...
smackie
 
Posts: 2
Joined: Tue Oct 29, 2013 1:32 pm


Return to Support