Automatically use date as version string?



I’ve got into the habit of using the current date (e.g. 2017.06.09) as the version string in my AppleScript bundles. Is there any way to insert the date automatically into the version field in the editor when building? If not, this is something I can certainly live without, but it would be nice to have.

If there is a way to do this, it’s probably obvious to every long-term user of SD, but I couldn’t figure out what it might be.

(Shane Stanley) #2

You could run a script from the Scripts menu:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set df to current application's NSDateFormatter's new()
df's setDateFormat:"yyyy.MM.dd"
set dateString to (df's stringFromDate:(current application's NSDate's |date|())) as text
tell application id "com.latenightsw.ScriptDebugger6" -- Script
	tell document 1
		if script type is in {bundled compiled script, script application} then
			set marketing version to dateString
		end if
	end tell
end tell


That works beautifully. Thank you.

I hope it’s OK to suggest a future enhancement that would let you specify a script that would automatically run before saving - either on a per-script basis or for all scripts. There might be other things that someone would want to do this way.

Meanwhile, thank you again for this script!