Download Bank Statement Almost Working

Love this Chris!

Since you mentioned ASObjC, are you using ASObjC Explorer 4?
It looks pretty nifty for debugging.

Hey John,

I do own a copy.

I also own Script Debugger, and I use that for regular AppleScript. (SD-5 doesn't support ASObjC though.)

-Chris

1 Like

Something tells me I should look into those. The script Debugger in Filemaker Advanced is so helpful it’s a no brainer to be looking at these as well. So many toys, so little time. :wink:

Edit 01/20/2016 4:27 PM… I was just looking over this entire thread and realized this is a gold mine of information. I am going to have to print it or clip it to Evernote or something.

Some time there is an issue with downloading the files.

@SaraParker, please post your question/issue in a new Topic, and provide a much detail as you can to describe exactly what is not working as you expect.

Chris,

Revisiting this after much tutorialing. This works beautifully in ScriptEditor. Where is the contents stored? I assume shCMD is either a variable or a standard command. I note it's not on the clipboard. pdftotext -layout - does not work. Is there a way I can dump the result either into a file or straight to the, or a clipboard? (Assuming it's not already in a file) The intent being to have KM parse it for a line in the file that has the account number and the date immediately following. Here's the output:

> " P.O. Box 56035 Member Statement Period: > Chicago, IL 60666 No: > (800) 328-1935 > 63753 04/01/20 thru 04/30/20 > > Account Summary

Also is the double quote " Coming from the output as well? Curious if I can use it as a possible starting point for parsing. Unless KM would not need it to snag the date of the file. I am snagging the date because the statements are named by the date of the statement so I can see them in order in a folder. (Note the > is the start of a new line, it didn't paste correctly)

In the AppleScript variable pdfText.

It would be best to add a command at the end:
return pdfText

to make it explicitly clear.

If you put this script in a KM Execute AppleScript, you can set that Action to receive the results in a variety of locations, including the System Clipboard, or a KM Variable.

shCMD is just an AppleScript text variable that stores the command to be run by the do shell script command, as shown in Chris' script:

set shCMD to text 2 thru -2 of ("
    export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:$PATH;
    pdftotext -layout " & (quoted form of posixFilePath) & " - 
  ")
  
  set pdfText to do shell script shCMD

I would save the results of the AppleScript to a KM Variable, and then use a KM Search using Regular Expression action using that variable as its source, to extract the date and any other data I wanted.

So does adding return store it somewhere such as a buffer?

No, it just returns the value of the variable from the script to whatever tool called the script.
As I said above, in the case of KM, you can capture the return value in the KM Action by setting the results option to any of these:

image

Got it. Thanks JMichael!

1 Like