Skip to content

Instantly share code, notes, and snippets.

@deyhle
Created April 23, 2017 19:56
Show Gist options
  • Save deyhle/6e1c0b7b14c2afa73f0e64dd982c3c58 to your computer and use it in GitHub Desktop.
Save deyhle/6e1c0b7b14c2afa73f0e64dd982c3c58 to your computer and use it in GitHub Desktop.
apple script to export all money money account data of the last 90 days as OFX to $HOME/Dropbox/MoneyMoney
#!/usr/bin/osascript
set backTo to ((current date) - 90 * days) as string
set now to (current date) as string
tell application "MoneyMoney"
set exported to export accounts
end tell
set tempDir to (path to temporary items as text)
set tempFile to tempDir & "accounts.xml"
set myFile to open for access tempFile with write permission
write exported to myFile
close access myFile
tell application "System Events"
set accounts to value of property list item "name" of every property list item of contents of property list file tempFile
end tell
repeat with i from 1 to count of accounts
set acc to item i of accounts
set newFileName to (acc & ".ofx")
try
tell application "MoneyMoney"
set result to export transactions from account acc from date backTo to date now as "ofx"
end tell
tell application "Finder"
set exportedFile to duplicate file result as POSIX file to folder "MoneyMoney" of folder "Dropbox" of folder (path to home folder)
delete (every item of folder "MoneyMoney" of folder "Dropbox" of folder (path to home folder) whose name is newFileName)
set name of exportedFile to newFileName
-- open result as POSIX file
end tell
end try
end repeat
return "all done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment