Skip to content

Instantly share code, notes, and snippets.

@gruber
Created August 8, 2012 03:51
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save gruber/3291908 to your computer and use it in GitHub Desktop.
Save gruber/3291908 to your computer and use it in GitHub Desktop.
Rename Active BBEdit Document
tell application "BBEdit"
activate
set old_name to name of text window 1
set dialog_result to display dialog "" default answer (old_name) ¬
buttons {"Cancel", "Rename"} default button 2 ¬
with icon note ¬
with title "Rename Active Document"
if button returned of dialog_result = "Rename" then
set new_name to text returned of dialog_result
set d to active document of text window 1
if (d's on disk) then
set the_file to d's file
tell application "Finder"
set name of file the_file to new_name
end tell
else -- it's a document that has never been saved
set name of d to new_name
end if
end if
end tell
@gruber
Copy link
Author

gruber commented Aug 8, 2012

Moved "Rename Active Document" to the title of the dialog box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment