Applescript - progressive loops get slower. Solutions?
Hi all,
I made a terrible Automator script and because it performed so badly (thanks to 'Watch Me Do') I eventually replaced every section with an Applescript action I wrote myself. My Applescript knowledge is limited so my scripts are rudimentary - but they work. My issue is that as it processes, each successive loop gets exponentially slower!
Here's what I'm tying to do:
We have 47 invoices with hundreds of lines of products in most of them. I have a list of product codes we should not have been charged and I need to ascertain if those codes appear on these invoices.
Here's my planned method:
- Extract the entire (text) contents of each PDF invoice and (prefaced by the PDF filename so I can identify the guilty invoice) paste it into TextEdit for 'massaging' into spreadsheet-friendly formatting.
- Copy and paste massaged content into Numbers and use the 'COUNTIF' function (or other suitable argument) to highlight instances of being charged
Here's my Automator script:
I know there are better more efficient scripts that will perform the same task better, but I'm keen to learn two things:
- Why does it get exponentially slower and how to prevent this for future scripts
- A more efficient way of getting this done. (Using Finder to search file contents of the enclosing folder doesn't work because the way the PDF's are constructed/formatted)
Any help or input is greatly appreciated.
Thanks!
Jeremy
MacBook Pro (Retina, Mid 2012), OS X Yosemite (10.10.5)