I'm really stuck. I want to keep a log of how many times a script is run. My script is the following
set actionlist to {"action1","action2}
--select an action
set actionlist to choose from list actionlist with prompt "hello" default items {"action1"} with title "Actions"
if actionlist is {"action1"} then
set thefile to quoted form of POSIX path of (choose file of type {"mov"})
tell application "Terminal"
do script "DO SCRIPT HERE"
activate
end tell
if actionlist is {"action2"} then
set thefile to quoted form of POSIX path of (choose file of type {"mp4"})
tell application "Terminal"
do script "DO SCRIPT HERE"
activate
end tell
I want a script-log.txt that counts any time and actions were executed. Something like this:
action1 = 14
action2 = 21
Is this possible? Thank you for your time!
This is doable in a few different ways, depending on what your intent is. Simplest would be to set up
propertieslike so:And then each time you do action 1 or action 2 increment the property:
The interesting thing about AppleScript properties is that they are retained across each run of the script so that you can build a cumulative total over time. The caveats are that:
Display Dialogwithin the script to show them in an alert, by loading the script from another script and reading them indirectly.If you prefer to write data to a file, you can use handlers like the following:
...The following is edited significantly per requests in comments...