I created an apple script (.scpt file) and I use it in a KM Macro.
I have that applescript in a cloud folder to sync.
The Macro is used for time stamping videos.
Every time I press the Keyboard shortcut to run the Macro,
I get a cloud sync popup that says the script.scpt has been modified.
I check the file and indeed the modified date is the current time.
Why does KM cause the .scpt file to update it’s modified date?
This creates a problem on cloud sync since I save versions in case of accidental changes to files.
Is this an expected behavior?
If so, does this mean I can’t use a cloud sync folder for my applescripts used in KM?
A scpt script file contains the text source of the script and also the compiled code. I don’t know the technical details why the script is changed each time, but it happens every time you execute the script via osascript. KM also runs the scripts via osascript, so the behavior is not limited to KM.
If this is a problem try one of these:
Save as text script
Save the script as text (with the .applescript extension) and run it as usual with the Execute AppleScript action:
Decompile and execute
Leave your script as it is (.scpt) and run it in the shell with
osadecompile <myScript.scpt> | osascript
You can do this in a Execute Shell Script KM action:
This will not work with all scripts, for example the changed values of properties are no longer stored this way. So, double-check if your scripts are working as they should.
Adding one more option: At the start of your macro, you could copy the script file to a local folder, and run it from there. Then it wouldn’t matter if it changed, because you wouldn’t sync it back to the cloud.
Thanks for the ideas.
Currently I only run the scripts using KM so I decided to cut and paste the Script into KM directly.
That seems to be working as expected.
It’s not very complex, just captures the filename and current time in VLC and writes the info to a file.
I can later run a script to create a batch process to extract clips from videos.
This has made it much faster to go through the 100’s of home videos to trim them down.
I had four test scripts, all compiled files (.scpt):
noVar.scpt: contains no variables
localVar.scpt: contains a variable that is set in a handler
globalVar.scpt: contains a variable that is set in the run handler (top level handler)
property.scpt: contains a property that gets changed on the first run
I have executed the scripts with
The noVar.scpt never changes, not with osascript, nor with FastScripts. This was expected.
localVar.scpt behaves exactly as noVar.scpt
globalVar.scpt executed with osascript:
1st run: md5 checksum changed and modification time changed
2nd run: checksum unchanged, but modification time changed
3rd run: checksum unchanged, but modification time changed again
So, it seems, on the 2nd and 3rd run the file is temporarily changed but then reverted back. (?)
globalVar.scpt executed with FastScripts:
1st run: checksum and modification time unchanged
2nd run: ditto
3rd run: ditto
property.scpt behaves exactly like globalVar.scpt.
Now I’m wondering:
Why do globalVar.scpt and property.scpt behave identically? I understand that property.scpt changes because of the changed value of the property. But why does globalVar.scpt also change (with osascript)?
Why does property.scpt not change when executed with FastScripts? Where is the changed property value stored?
(Extended attributes, including resource fork, are also unchanged.)