on run {input, parameters} tell application "Finder" to set save_folder to (target of window 1) as alias tell application (path to frontmost application as Unicode text) try set text_file to choose file name with prompt "Anna tiedoston nimi: " default location save_folder on error number -128 --user cancelled; stop execution return end try end tell set file_ref to open for access text_file with write permission set eof file_ref to 0 close access file_ref tell application "Finder" set file type of (text_file as alias) to "TEXT" set creator type of (text_file as alias) to "ttxt" end tell tell application "TextMate" activate open text_file end tell end run