Hi Im trying to extract dates from PDF's to rename my files accordingly
Im running this script and get this error
Im trying to do this but I keep getting an error.
My script is this
set itemPath to quoted form of POSIX path of theFile
set dateString to do shell script "/usr/local/bin/pdftotext " & itemPath & " - | awk 'NR < 2 {print $1, $8}'"
set stmMonth to word 1 of dateString
if stmMonth is "January" then
set stmMonth to "01"
else if stmMonth is "February" then
set stmMonth to "02"
else if stmMonth is "March" then
set stmMonth to "03"
else if stmMonth is "April" then
set stmMonth to "04"
else if stmMonth is "May" then
set stmMonth to "05"
else if stmMonth is "June" then
set stmMonth to "06"
else if stmMonth is "July" then
set stmMonth to "07"
else if stmMonth is "August" then
set stmMonth to "08"
else if stmMonth is "September" then
set stmMonth to "09"
else if stmMonth is "October" then
set stmMonth to "10"
else if stmMonth is "November" then
set stmMonth to "11"
else if stmMonth is "December" then
set stmMonth to "12"
end if
return {hazelExportTokens:{stmMonth:stmMonth, StmYear:word 2 of dateString}}
Tokens are stmMonth and stmYear
I get this error
2015-10-21 09:16:25.842 hazelworker[2204] Untitled.pdf: Rule Natwest Credit Card Statements matched.
2015-10-21 09:16:25.916 hazelworker[2204] [Error] AppleScript failed: Error executing AppleScript on file /Users/jameskelly/Google Drive/Scans/Untitled.pdf.
2015-10-21 09:16:25.917 hazelworker[2204] OSAScript error: {
NSLocalizedDescription = "Can\U2019t get word 1 of \"\".";
NSLocalizedFailureReason = "Can\U2019t get word 1 of \"\".";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: null()>";
OSAScriptErrorBriefMessageKey = "Can\U2019t get word 1 of \"\".";
OSAScriptErrorMessageKey = "Can\U2019t get word 1 of \"\".";
OSAScriptErrorNumberKey = "-1728";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'obj '{ 'form':'indx', 'want':'cwor', 'seld':1, 'from':'utxt'(\"\") }>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
Any ideas or help
Thanks
James