Get BBEdit active file in project with AppleScript

Posted in AppleScript on April 20, 2017 · 1 min read
How can you get the BBEdit active document in AppleScript?

To get the active document in AppleScript you would target the application:

tell application "BBEdit"

end tell

After indicating what application we are using we must ensure it is active:

tell application "BBEdit"
    activate
end tell

Since we have activated the app we can target the project's active document with:

tell application "BBEdit"
    activate
    set workingFile to (name of active document of project window 1)
end tell

if you'd like to get a display of the name you can:

tell application "BBEdit"
    activate
    set workingFile to (name of active document of project window 1)
    display dialog workingFile as text
end tell

if you do not want the display but do want to see the result, you can enable the log in Script Editor then change the script to:

tell application "BBEdit"
    activate
    set workingFile to (name of active document of project window 1)
    return workingFile
end tell
Help the site go ad free:
Storm Trooper