How to save out all my unsaved untitled files

338 views
Skip to first unread message

Steve Weiss

unread,
Mar 29, 2021, 11:21:54 AM3/29/21
to BBEdit Talk
I use BBEdit as my general purpose clipboard and I've amassed over a thousand unsaved documents, which I still will refer back to even years after they were created.  Every time BBEdit restarts those unsaved files are still there.  They never go away.  I don't close them all because I want to retain the information within them, but, lately it's become a problem because at startup BBEdit will load this 1K files, some of which contain hundreds of MB of data.  This then slows down my computer, slows down BBEdit, and generally just makes life harder.

What I would like to do, is take all of these unsaved, untitled documents and save them all out to a folder so that I can just grep through them without having to use the Find feature in BBEdit - and then close all of the documents so I don't have to keep reopening all of them. 

How can I do this without having to press save on every single file individually?  I've seen applescripts but they all seem to assume the files have already been saved once.

Thanks for any advice!
Steve Weiss | CTO
347-308-5377st...@wgacany.com
812 Jersey Ave, 8th Fl, Jersey City, NJ 07310

bruce linde

unread,
Mar 29, 2021, 11:24:14 AM3/29/21
to 'Gregory Shenaut' via BBEdit Talk
first off, why wouldn’t you save them?

second, hold the option key while viewing the file menu… you’ll see ’save all’    😇






Steve Weiss | CTO
347-308-5377 st...@wgacany.com
812 Jersey Ave, 8th Fl, Jersey City, NJ 07310

-- 
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" 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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/645a86a2-a024-4c12-8876-60388030fc16n%40googlegroups.com.





bruce linde
5 happiness webmaster (four more than the competition!)
http://www.5happy.com/
http://clockhappy.com/
510.530.1331 office
510.206.9730 mobile

(shift key available upon request)








Steve Weiss

unread,
Mar 29, 2021, 11:30:34 AM3/29/21
to BBEdit Talk
I see that option but then I still have to name each file and press save on each one.  I really just want to save them all with their "untitled text xxxx" as the filename in one operation and not have to confirm the filename on each document.  Otherwise this could take several hours.  

It's a clipboard, I'll copy a column out of excel, paste it in, run a regex, and paste it back, several times a day.  Or, I'll take a forum post, and instead of typing it in on the website (and risk losing it due to an errant click or back button) I'll write it in BBEdit and paste it in when I'm done, etc, etc (I am doing this, right now).  Or it could be a confirmation code someone gave me over the phone, or a password (I know, I know, I am not as security obsessed as thou).  Especially because I know BBEdit won't lose any of these snippets, I just go about my life and don't take the time to sit here and decide, yes, this should be saved and this shouldn't.  Maybe my life is just too busy, maybe I'm just lazy, maybe a little bit of both.  But now I'd really just like to be able to start BBEdit without waiting 20 minutes and I also don't want to lose all of these snippets, some of them might be important one day.  I'm a digital hoarder.

Steve Weiss | CTO
347-308-5377st...@wgacany.com
812 Jersey Ave, 8th Fl, Jersey City, NJ 07310
On Monday, March 29, 2021 at 11:24:14 AM UTC-4 Bruce Linde wrote:
first off, why wouldn’t you save them?

second, hold the option key while viewing the file menu… you’ll see ’save all’    😇






On Mar 29, 2021, at 8:20 AM, Steve Weiss <st...@wgacany.com> wrote:

I use BBEdit as my general purpose clipboard and I've amassed over a thousand unsaved documents, which I still will refer back to even years after they were created.  Every time BBEdit restarts those unsaved files are still there.  They never go away.  I don't close them all because I want to retain the information within them, but, lately it's become a problem because at startup BBEdit will load this 1K files, some of which contain hundreds of MB of data.  This then slows down my computer, slows down BBEdit, and generally just makes life harder.

What I would like to do, is take all of these unsaved, untitled documents and save them all out to a folder so that I can just grep through them without having to use the Find feature in BBEdit - and then close all of the documents so I don't have to keep reopening all of them. 

How can I do this without having to press save on every single file individually?  I've seen applescripts but they all seem to assume the files have already been saved once.

Thanks for any advice!

Christopher Stone

unread,
Mar 29, 2021, 11:38:07 AM3/29/21
to BBEdit-Talk
On 03/29/2021, at 10:20, Steve Weiss <st...@wgacany.com> wrote:
What I would like to do, is take all of these unsaved, untitled documents and save them all out to a folder so that I can just grep through them without having to use the Find feature in BBEdit - and then close all of the documents so I don't have to keep reopening all of them. 

How can I do this without having to press save on every single file individually?  I've seen applescripts but they all seem to assume the files have already been saved once.


Hey Steve,

"Easily" done.

I've commented-out the commands that close the documents after saving, so you can verify everything before closing them.  (I'm confident it works on my system, so I am no longer concerned about this – but on first run especially on a newer system I'd want to verify.)

--
Best Regards,
Chris



--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/10/18 03:00
# dMod: 2021/03/29 10:33
# Appl: BBEdit
# Task: Save unsaved text documents and shell documents to a date-stamped folder in the Finder.
#     : Then close those documents and open the folder in the Finder.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @Finder, @Save, @Unsaved, @Text_Documents, @Shell_Documents
--------------------------------------------------------

set saveFolderWasCreated to false

tell application "BBEdit"

    

    set unsavedDocList to text documents whose on disk is false

    

    if length of unsavedDocList > 0 then

        

        set saveFolderPath to makeSaveFolder() of me
        set saveFolderWasCreated to true

        

        repeat with theDoc in unsavedDocList
            set docName to name of theDoc
            set docName to findReplTIDS(":", ";", docName) of me
            set docID to ID of theDoc
            save theDoc to (saveFolderPath & docName) & ".txt"
            # close document id docID
        end repeat

        

    end if

    

    set unsavedShellDocList to every shell document whose on disk is false

    

    if length of unsavedShellDocList > 0 then

        

        if not saveFolderWasCreated then
            set saveFolderPath to makeSaveFolder()
            set saveFolderWasCreated to true
        end if

        

        repeat with theDoc in unsavedShellDocList
            set docID to ID of theDoc
            save theDoc to (saveFolderPath & (name of theDoc)) & ".worksheet"
            # close document id docID
        end repeat

        

    end if

    

end tell

if saveFolderWasCreated then
    tell application "Finder"
        activate
        open (alias saveFolderPath)
    end tell
end if

--------------------------------------------------------
--» HANDLERS
--------------------------------------------------------
on findReplTIDS(_find, _replace, _string)
    set oldTIDS to AppleScript's text item delimiters
    set AppleScript's text item delimiters to _find
    set _string to text items of _string
    set AppleScript's text item delimiters to _replace
    set _string to _string as text
    set AppleScript's text item delimiters to oldTIDS
    return _string
end findReplTIDS
--------------------------------------------------------
on makeSaveFolder()
    set newFolderName to do shell script "date \"+%Y-%m-%d %H.%M\""
    set newFolderName to "BBEdit → Untitled Docs → Saved " & newFolderName
    tell application "Finder"
        set newFolder to make new folder at (path to desktop folder) with properties {name:newFolderName}
        return newFolder as text
    end tell
end makeSaveFolder
--------------------------------------------------------

bruce linde

unread,
Mar 29, 2021, 11:38:39 AM3/29/21
to bbe...@googlegroups.com
On Mar 29, 2021, at 8:29 AM, Steve Weiss <st...@wgacany.com> wrote:
I see that option but then I still have to name each file and press save on each one.  I really just want to save them all with their "untitled text xxxx" as the filename in one operation and not have to confirm the filename on each document.  Otherwise this could take several hours.  
It's a clipboard, I'll copy a column out of excel, paste it in, run a regex, and paste it back, several times a day.  Or, I'll take a forum post, and instead of typing it in on the website (and risk losing it due to an errant click or back button) I'll write it in BBEdit and paste it in when I'm done, etc, etc (I am doing this, right now).  Or it could be a confirmation code someone gave me over the phone, or a password (I know, I know, I am not as security obsessed as thou).  Especially because I know BBEdit won't lose any of these snippets, I just go about my life and don't take the time to sit here and decide, yes, this should be saved and this shouldn't.  Maybe my life is just too busy, maybe I'm just lazy, maybe a little bit of both.  But now I'd really just like to be able to start BBEdit without waiting 20 minutes and I also don't want to lose all of these snippets, some of them might be important one day.  I'm a digital hoarder.



you’re not just a digital hoarder, you’re a DHP… a digital hoarder procrastinator.   8-)

i can’t even fathom how you would know which file contains what you need when you need it, but you should have been naming them as you went. it’s payback time.

you’ll probably need an AppleScript to automatically hit ’save’ for you as it cycles through all of the windows… but would still end up with ‘untitled_text_257.txt’, etc.

of course, bbedit might actually be saving the ‘unsaved’ docs somewhere… perhaps someone from the mothership can comment on that.

and… it really wouldn’t take you that long to click ’save’ 1000x during the process…. organize some paperwork, line up your taxes, whatever, while monitoring the screen (or call your mother)











Steve Weiss

unread,
Mar 29, 2021, 11:58:16 AM3/29/21
to BBEdit Talk
You are my hero Chris.  That worked perfectly.  I haven't seen BBEdit run this fast in years.  Thank you, thank you, thank you.

--
Steve

Steve Weiss | CTO
347-308-5377st...@wgacany.com
812 Jersey Ave, 8th Fl, Jersey City, NJ 07310
On Monday, March 29, 2021 at 11:38:39 AM UTC-4 Bruce Linde wrote:
On Mar 29, 2021, at 8:29 AM, Steve Weiss <st...@wgacany.com> wrote:
I see that option but then I still have to name each file and press save on each one.  I really just want to save them all with their "untitled text xxxx" as the filename in one operation and not have to confirm the filename on each document.  Otherwise this could take several hours.  
It's a clipboard, I'll copy a column out of excel, paste it in, run a regex, and paste it back, several times a day.  Or, I'll take a forum post, and instead of typing it in on the website (and risk losing it due to an errant click or back button) I'll write it in BBEdit and paste it in when I'm done, etc, etc (I am doing this, right now).  Or it could be a confirmation code someone gave me over the phone, or a password (I know, I know, I am not as security obsessed as thou).  Especially because I know BBEdit won't lose any of these snippets, I just go about my life and don't take the time to sit here and decide, yes, this should be saved and this shouldn't.  Maybe my life is just too busy, maybe I'm just lazy, maybe a little bit of both.  But now I'd really just like to be able to start BBEdit without waiting 20 minutes and I also don't want to lose all of these snippets, some of them might be important one day.  I'm a digital hoarder.



you’re not just a digital hoarder, you’re a DHP… a digital hoarder procrastinator.   8-)

i can’t even fathom how you would know which file contains what you need when you need it, but you should have been naming them as you went. it’s payback time.

you’ll probably need an AppleScript to automatically hit ’save’ for you as it cycles through all of the windows… but would still end up with ‘untitled_text_257.txt’, etc.

of course, bbedit might actually be saving the ‘unsaved’ docs somewhere… perhaps someone from the mothership can comment on that.

and… it really wouldn’t take you that long to click ’save’ 1000x during the process…. organize some paperwork, line up your taxes, whatever, while monitoring the screen (or call your mother)












Steve Weiss

unread,
Mar 29, 2021, 12:00:07 PM3/29/21
to BBEdit Talk
Oh I should add - I don't really need to remember where the notes are.  I just use Multi-File search across all open text documents.  It's usually pretty effective.  There have been times though where I've sat clicking through my last 10-15 unsaved files one by one.  Trust me,  the payback has been happening!

BBEdit does seem to have the files all on disk but they all appear to be encrypted or encoded in some way, I couldn't just grep for things in them.
Reply all
Reply to author
Forward
0 new messages