Let me ask a clarification question: are you saying:
That there are no unsaved changes at this point, and you just want to close everything because you are absolutely sure that any changes you wanted to save are already saved?
or
There may be unsaved changes in files that you want to save, but those files will have previously been saved (and will therefore have a given filename already), so you want to save those files, but close any untitled documents without saving them?
This is an AppleScript that I have from the BBEdit user group (mailing list) which will:
Automatically save all previously-saved files using their previously given filenames
Not try to save any files which have not been previously saved:
-- With thanks to Christopher Stone and Rich Siegel
-- Source: https://groups.google.com/d/topic/bbedit/dfT5wJY5wSI/discussion
if application "BBEdit" is running then
try
tell application "BBEdit"
set docList to (text documents whose on disk is true and modified is true)
repeat with theDoc in docList
save theDoc
end repeat
end tell
end try
end if
(Aside: I have a Keyboard Maestro macro that runs that AppleScript whenever BBEdit deactivates and every 1 minute while BBEdit is active.)
I would assume that it would be fairly easy to modify that AppleScript to:
Close the file after saving it (if it needs to be saved, by the criteria already specified)
Close the rest of the files without prompting you to save them.
However, I do not speak AppleScript well enough to tell you how to do that.
My recommendation would be to ask on the BBEdit user group because someone there will certainly know the best way to do this.
If, by some weird chance, you do not get a good answer there, I would contact BBEdit support directly because they will 100% know the answer.
(Why try the user group first? Because then others can benefit from the discussion and answer(s) that are given.)
I greatly appreciate your comments. I want to close all because I saved what's important. That being said, my method does not provide a failsafe in case I forgot to save one of 60 documents.
I think that @JMichaelTX's method using the Opt menu is optimal.
Ability to close all quickly + a quick glance at those files which will be closed without saving.
I hope that you will not be offended that I don't take the script route.
thanks again. I can write a macro with a simple keystroke, but for didactic reasons only, how do you access a menu item which only appears when you press the Opt key ?
I think Keyboard Maestro's menu item list should show all of the menu items, but if it doesn't then I would just fine one that is close, use that, and then edit the last line to match what you want. Be careful of capitalization and spelling, both of which have to be precise.
Thank you both @JMichaelTX and @tjluoma for both solutions (see directly or modify the menu)
There is one situation which remains obscure: when the context menu changes when the option key is pressed.
Example: the Evernote context menu when you right click in the Notes List.
As per illustration 1, below, Copy Note Link becomes Copy Classic Note Link (much much more useful) if I press on the option key as I trigger the context menu.
A while back I tried in vain to create a macro to do so.
The following does not work:
finding a new item: there is none
the right mouse click with option button action
just now after reading @tjluoma's post today I tried modifying the menu item (Copy Note Link) but it did not work : error message = menu item not found.
First, context menus and normal menus (in the Apple bar) are different, and are handled differently. It is up to the app developer to provide consistency, which Evernote does not.
Second, Evernote uses the dynamic menu approach, which means that the menu items are NOT available to KM (or AppleScript) until the menu is actually shown.
In this case the OPT key causes a new/different menu item.
You will need to use AppleScript to create the classic link by other means. I think I have provided this to you previously.
Indeed the AppleScript is the solution.
My question was specifically about using KBM actions to tackle dynamic menus and context dynamic menus. I just happened to take Evernote as an example, not a specific request about Evernote.
thank you for your comment
KM can't really help with this. It takes an AppleScript to tell the app UI to show the menu (perform action "AXShowMenu"), or click on the parent menu to show it.