How to read and save prefs to text or plist?
You don’t say what you want to save, but here’s a script I wrote that saves how many times a script/app has been run:
try
set runs to (do shell script "defaults read ScriptRunCount theCount")
-- ScriptRunCount is the name of the variable
-- theCount is the value as text
set runs to 1 + runs
do shell script ("defaults write ScriptRunCount theCount " & runs as text)
on error --> no such file yet
set runs to 1
do shell script ("defaults write ScriptRunCount theCount " & runs as text)
end try
display dialog "This script has run " & (do shell script "defaults read ScriptRunCount theCount") & " times."