I am trying to figure out how to save the contents of all my currently open terminal sessions to text file. I am still trying to grasp the applescript metaphor but in psuedo code this is what I would like to acomplish
for each terminal window
copy contents(text) of window to unique text file
Any suggestions for a starting point?
Browser: Firefox 1.4.1
Operating System: Mac OS X (10.4)
property scrapFolder : path to desktop as text
property scrapNamePrefix : "Terminal scrap "
tell application "Terminal"
launch
repeat with i from 1 to (count windows)
try
open for access (scrapFolder & scrapNamePrefix & i & ".txt") with write permission
set theFileRef to result
get contents of window i
write result to theFileRef
close access theFileRef
on error errorMsg number errorNum
try
close access theFileRef
end try
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
end repeat
end tell
Note that this particular script will overwrite the text files that it generates.