|
-- 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/7376020C-4DEF-4C0E-AFD0-3DD74F458BE3%40gmail.com. |
<<attachment: Parse_the_BBEdit_Saved-State_File_for_Open_File_Paths.scptd.zip>>
Hey Sam, I'll take that challenge. 😎 It wasn't simple by any means, but it wasn't especially difficult either. I'm naming the document in BBEdit but saving it is left to the user. If I was doing this for myself I'd auto-save the file to a specific location on my hard drive, but I'm done for the day. -- Best Regards, Chris -------------------------------------------------------- # Auth: Christopher Stone <[email protected]> # dCre: 2021/03/18 21:10 # dMod: 2021/03/18 21:27 # Appl: BBEdit, Finder, System Events # Task: Parse the BBEdit Saved-State File for Open File Paths. # Libs: None # Osax: None # Tags: @Applescript, @Script, @ASObjC, @Finder, @System_Events, @Parse, @BBEdit, @Saved-State -------------------------------------------------------- use framework "Foundation" use scripting additions -------------------------------------------------------- set bbeditLibFolderAlias to ((path to library folder from user domain as text) & "BBEdit") as alias set tempDirAlias to (path to temporary items from user domain) tell application "Finder" set bbeditSavedStateFile to (files of bbeditLibFolderAlias whose name starts with "Saved Application State") as alias list if length of bbeditSavedStateFile = 1 then set {bbeditSavedStateFile} to bbeditSavedStateFile else error "Too many saved-state files were found!" end if set tempSavedStateFile to (duplicate bbeditSavedStateFile to tempDirAlias with replacing) as alias end tell set tempSavedStateFilePath to POSIX path of tempSavedStateFile set fileURLList to {} tell application "System Events" tell property list file tempSavedStateFilePath tell property list item "OpenDocuments" set itemList to (get property list items's value) repeat with i in itemList try set urlString to i's |Location|'s |FileURLString| tell AppleScript set posixPath to (current application's class "NSURL"'s URLWithString:urlString)'s |path|() as text set end of fileURLList to posixPath end tell end try end repeat end tell end tell end tell set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, linefeed} set fileURLList to fileURLList as text set AppleScript's text item delimiters to oldTIDS set newDocName to "BBEdit Open Files – " & dateStamp(current date) & ".txt" tell application "BBEdit" activate make new document with properties {name:newDocName, text:fileURLList, bounds:{303, 45, 1617, 1196}} end tell -------------------------------------------------------- --» HANDLERS -------------------------------------------------------- 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 -------------------------------------------------------- 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/7376020C-4DEF-4C0E-AFD0-3DD74F458BE3%40gmail.com. |
