I rewrote my Save-Session script for Script Debugger to use symlinks instead of aliases to reference saved scripts. It is now much faster.
The script saves symlinks to open script files and .applescript files for unsaved script documents to a date-stamped folder.
-------------------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2014/03/08 03:02
# dMod: 2014/03/10 02:44
# Appl: Script Debugger
# Task: Save Script Debugger Session:
# Save sym-links to open script files & unsaved script source to saved-sessions folder.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Script_Debugger, @Save, @Session
# Vers: 1.2
-------------------------------------------------------------------------------------------
try
set saveLoc to "~/Documents/Code_Projects/Script_Debugger/Saved-Sessions/"
set svFldrBaseName to "sd-saved-session-"
set AppleScript's text item delimiters to linefeed
tell application "Script Debugger"
tell (documents whose path contains "/") to set {fileList, nameList} to {text items of (file spec as text), name}
tell (documents whose path does not contain "/" and source text ≠ "") to set unSavedSrc to source text
end tell
set newSvFldr to xpndHome(saveLoc) & svFldrBaseName & dateStamp()
if fileList ≠ {} or unSavedSrc ≠ {} then
repeat with i from 1 to length of fileList
tell (a reference to item i of fileList)
set its contents to "ln -s " & my qf((POSIX path of (its contents))) & " " & (my qf(item i of nameList)) & ";"
end tell
end repeat
set beginning of fileList to "cd \"$DIR\";"
set beginning of fileList to "mkdir -p \"$DIR\";"
set beginning of fileList to "DIR=" & qf(newSvFldr) & ";"
set _cmd to fileList as text
do shell script _cmd
set _cntr to 0
repeat with _src in unSavedSrc
if (contents of _src) ≠ "" then
set _cntr to _cntr + 1
writeUTF8(_src, (newSvFldr & "/Unsaved-Script-Source-" & zPad(_cntr) & ".applescript"))
end if
end repeat
else
error "Nothing is available to save!"
end if
on error e number n
stdErr(e, n, true, true) of me
end try
-------------------------------------------------------------------------------------------
on dateStamp()
tell (current date) to (((its year) * 10000 + (its month) * 100 + (its day)) as text) & text 2 thru -1 of ((1000000 + (its hours) * 10000 + (its minutes) * 100 + (its seconds)) as text)
tell result to (text 1 thru 4) & "." & (text 5 thru 6) & "." & (text 7 thru 8) & "-" & (text 9 thru 10) & "." & (text 11 thru 12) & "." & (text 13 thru 14)
end dateStamp
-------------------------------------------------------------------------------------------
on qf(_text)
return quoted form of _text
end qf
-------------------------------------------------------------------------------------------
on stdErr(e, n, beepFlag, ddFlag)
set e to e & return & return & "Num: " & n
if beepFlag = true then
beep
end if
if ddFlag = true then
tell me
set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
end tell
if button returned of dDlg = "Copy" then set the clipboard to e
else
return e
end if
end stdErr
-------------------------------------------------------------------------------------------
on writeUTF8(_text, _file)
try
if _file starts with "~/" then
set _file to POSIX path of (path to home folder as text) & text 3 thru -1 of _file
end if
set fRef to open for access _file with write permission
set eof of fRef to 0
write _text to fRef as «class utf8»
close access fRef
on error e number n
try
close access fRef
on error e number n
error "Error in writeUTF8() handler!" & return & return & e
end try
end try
end writeUTF8
-------------------------------------------------------------------------------------------
on xpndHome(_path)
if _path starts with "~/" then
set _path to (POSIX path of (path to home folder as text)) & text 3 thru -1 of _path
else
error "Bad path string!"
end if
end xpndHome
-------------------------------------------------------------------------------------------
on zPad(_num)
text 2 thru -1 of ((_num + 100) as text)
end zPad
-------------------------------------------------------------------------------------------