> On Jul 23, 2021, at 10:03, Jim Straus <[email protected]> wrote:
> 
> I've created a script to convert all my untitled text documents to notes 
> (kind of surprised something like this wasn't provided with the release of 
> BBEdit 14).  It generally works, but for some notes the body is empty.  If I 
> put in a dialog with the text, it works, but that means I have to respond to 
> each dialog.
> 
> Any thoughts on how to fix this?

Hey Jim,

It would be nice if Rich added a make new note command to the AppleScript 
dictionary, but this should work for now.

I recommend commenting-out close theDoc until you're confident the script works 
as intended.

--
Best Regards,
Chris


--------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/07/23 10:57
# dMod: 2021/07/23 10:57 
# Appl: BBEdit, System Events
# Task: Convert Unsaved Documents into Notes.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @BBEdit, @System_Events, @Convert, @Unsaved, 
@Documents, @Notes
# Test: Only on macOS 10.14.6 Mojave
# Vers: 1.00
--------------------------------------------------------

tell application "BBEdit"
    
    set docList to text documents whose name starts with "untitled" and on disk 
is false
    
    repeat with theDoc in docList
        if (length of theDoc's text > 0) then
            select theDoc
            select theDoc's text
            saveSelectedTextAsNote() of me
            close theDoc
        end if
    end repeat
    
end tell

--------------------------------------------------------
--ยป HANDLERS
--------------------------------------------------------
on saveSelectedTextAsNote()
    tell application "System Events"
        tell application process "BBEdit"
            tell menu bar 1
                tell menu bar item "File"
                    tell menu 1
                        tell menu item "Save as Note"
                            perform action "AXPress"
                        end tell
                    end tell
                end tell
            end tell
        end tell
    end tell
end saveSelectedTextAsNote
--------------------------------------------------------

-- 
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/B908AB4C-47D5-48D6-9033-3ED67CED4584%40gmail.com.

Reply via email to