I've been working with large file sets in TextWrangler recently. There is usually one window with 20 to 30 open documents. Lastly, these documents are on a server. It's a real pain to have to go back on and open each file by hand everytime I close the window, especially since they are in all over the place in different directories. It would be nice to be able to save a set of files and then come back and reopen them all later. So, I wrote two AppleScripts for doing just that.
This AppleScript saves the URL locations (local and remote) of all the documents in a single window.
tell application "TextWrangler"
set alldocs to every text document of text window 1
set allfiles to {}
set str to ""
repeat with adoc in alldocs
if is FTP of adoc then
set ftpinfo to FTP Info of adoc
set murl to URL of ftpinfo
else
set murl to URL of adoc
end if
set end of allfiles to murl
set str to str & "||" & murl
end repeat
set filename to (choose file name default name "TextWrangler Docs.txt")
set saver to make new text document
open saver opening in new_window
set text of saver to "--docsaver do not edit this line" & str
save saver to filename
close saver
end telltell application "TextWrangler"
set filename to (choose file)
open filename opening in new_window
set allfilesstr to text of text document 1
close text document 1
set allfiles to rest of my splitit(allfilesstr, "||")
set hasFTP to false
repeat with afile in allfiles
if afile contains "ftp" then
set hasFTP to true
end if
end repeat
set ps to ""
if hasFTP then
set ps to text returned of (display dialog "Type your password of the server your files are on" default answer "")
end if
if length of allfiles is greater than 0 then
set afile to item 1 of allfiles
set afile to my snr(afile, ":@", (":" & ps & "@"))
open location afile
end if
set allfiles to rest of allfiles
repeat with afile in allfiles
set afile to my snr(afile, ":@", (":" & ps & "@"))
open location afile
end repeat
end tell
on snr(the_string, search_string, replace_string)
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, search_string}
set {the_string, contents} to {the_string's text items, replace_string}
set {the_string, contents} to {the_string as Unicode text, old_tid}
end tell
return the_string
end snr
on splitit(the_string, search_string)
tell (a reference to my text item delimiters)
set {old_tid, contents} to {contents, search_string}
set {arr, contents} to {the_string's text items, old_tid}
end tell
return arr
end splitit
Mac OS X Hints
http://hints.macworld.com/article.php?story=20071024121225545