Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mobilemario

macrumors member
Original poster
Mar 26, 2009
63
17
I’m researching if it’s possible to achieve the fallowing:
I have a file named XYZ-DATE_CREATED*DUE*-DATE_DUE-1234.
It’s a credit card statement in pdf format.
XYZ- Name of the bank
DATE_CREATED- Original date of the statement
DATE_DUE- The date when payment is due.


Is there a way to use applescript to automatically create a reminder
with the due date grabbed from the file's name and the last 4digits and bank as the title?
I have zero knowledge about scripting so only trying to find a solution.
 
grep and its ^ and $ for start and end of expression to find could be used with a cron job to do what you want but I am failing to see why you do not use Reminders it has what you need already builtin to OSX.
 
I have a total of 12 statements, with various dates. Would like automate things a bit ;)
 
Is there a way to use applescript to automatically create a reminder with the due date grabbed from the file's name and the last 4digits and bank as the title?

Sure there is.

If you're looking for a pure AppleScript solution then do some reading up on Applescript's text item delimiters. Here's a little to get you started:

Code:
set theFileName to "XYZ-DATE_CREATED*DUE*-DATE_DUE-1234.pdf" --just using the example file name

--split the file name up into bits, separated by "-", and get the second 'bit'
set AppleScript's text item delimiters to "-"
set theTextItems to every text item of theFileName
set AppleScript's text item delimiters to ""
set theTempItem to item 2 of theTextItems


--take that second bit, and split it again, this time splitting it by "*" and getting the first bit
set AppleScript's text item delimiters to "*"
set theTextItems to every text item of theTempItem
set AppleScript's text item delimiters to ""

set theDateCreated to item 1 of theTextItems

display dialog "Date Created: " & theDateCreated
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.