On 03/17/2021, at 18:41, Bill Kochman <[email protected] <mailto:[email protected]>> wrote: > So, I must ask you then. Does the fact that you are taking interest in this > mean that there is not just one file somewhere in BBEdit’s folder and file > hierarchy where this information is stored?
It looks like Google Groups ate my text, since the attachment was at the top of my email, so I'm resending the body. Hey Bill, Sam showed you where the file was. It seems my memory was faulty, or it dates back to before the saved-state file existed... :-) Personally I would not depend upon the saved-state file, as it's mutable and will change right at the moment you don't want it to. Even if you saved various versions of it, you still have to parse it, extract the file-URLs, convert them into a usable format, and open them. The attached script will create a date-stamped folder of aliases to all files open in BBEdit at the time the script is run. Give it a keyboard shortcut like Control-S, and you can create a new save-state on demand. To open the files go to the saved-state folder, select all the aliases, and hit Cmd-O in the Finder. It wouldn't be hard to write a script to open the last saved-state, or even one to provide a list of saved-states to pick from. There are other ways to do this of course, but let's start here. -- Best Regards, Chris -------------------------------------------------------- # Auth: Christopher Stone <[email protected] <mailto:[email protected]>> # dCre: 2021/03/18 19:06 # dMod: 2021/03/18 19:06 # Appl: BBEdit, Finder # Task: Create Aliases of All Files Open in BBEdit in a Date-Stamped Folder. # Libs: None # Osax: None # Tags: @Applescript, @Script, @ASObjC, @BBEdit, @Finder, @Saved, @State -------------------------------------------------------- use AppleScript version "2.4" --» Yosemite or later use framework "Foundation" use scripting additions -------------------------------------------------------- --» USER SETTING -- Saved State Location -------------------------------------------------------- set bbeditSavedStateFolderPath to "~/Documents/BBEdit Saved-State/" -------------------------------------------------------- set bbeditSavedStateFolderPath to my expandTildeInPath:bbeditSavedStateFolderPath if itemExists(bbeditSavedStateFolderPath) = false then my createDirectoryAtPathWithIntermediates:bbeditSavedStateFolderPath end if set dateStr to my dateStamp(current date) set newFolderName to "BBEdit Saved State – " & dateStr tell application "BBEdit" set AppleScript's text item delimiters to linefeed set fList to (file of documents whose on disk is true) end tell tell application "Finder" set destFldr to (make new folder at (POSIX file bbeditSavedStateFolderPath) with properties {name:newFolderName}) as alias repeat with i in fList make new alias file at destFldr to i end repeat end tell -------------------------------------------------------- --» HANDLERS -------------------------------------------------------- on createDirectoryAtPathWithIntermediates:thePath set {theResult, theError} to current application's NSFileManager's defaultManager()'s createDirectoryAtPath:thePath ¬ withIntermediateDirectories:true attributes:(missing value) |error|:(reference) if not (theResult as boolean) then set errorMsg to theError's localizedDescription() as text error errorMsg end if end createDirectoryAtPathWithIntermediates: -------------------------------------------------------- on dateStamp(theDate) set dateDelim to "-" set timeDelim to "." tell theDate as «class isot» as string to ¬ set {yyyy, mm, dd, hh, mm, ss} to ¬ {its text 1 thru 4, its text 6 thru 7, its text 9 thru 10, its text 12 thru 13, its text 15 thru 16, its text 18 thru 19} return yyyy & dateDelim & mm & dateDelim & dd & space & hh & timeDelim & mm & timeDelim & ss end dateStamp -------------------------------------------------------- on expandTildeInPath:tildeBasedPath set expandedPath to (current application's NSString's stringWithString:tildeBasedPath)'s stringByExpandingTildeInPath return expandedPath as text end expandTildeInPath: -------------------------------------------------------- on itemExists(posixPath) --> Boolean output set posixPath to (current application's NSString's stringWithString:posixPath)'s stringByExpandingTildeInPath set myNSURL to current application's |NSURL|'s fileURLWithPath:posixPath set itemExistsBool to (myNSURL's checkResourceIsReachableAndReturnError:(missing value)) as boolean return itemExistsBool end itemExists -------------------------------------------------------- -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "[email protected]" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/95D50153-6BA1-42B9-A3D6-07337808E06C%40gmail.com.
