use AppleScript version "2.3"
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to POSIX path of (choose file of type {"scpt", "scptd"})
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set theScript to current application's NSAppleScript's alloc()'s initWithContentsOfURL:theURL |error|:(missing value)
set theAttSource to theScript's richTextSource()
set docTypeDict to current application's NSDictionary's dictionaryWithObject:(current application's NSHTMLTextDocumentType) forKey:(current application's NSDocumentTypeDocumentAttribute)
set theData to theAttSource's dataFromRange:{0, theAttSource's |length|()} documentAttributes:docTypeDict |error|:(missing value)
set newURL to theURL's URLByDeletingPathExtension()'s URLByAppendingPathExtension:"html"
theData's writeToURL:newURL atomically:true
display dialog "Finished"