BBEdit Question

I have a BBEdit script that needs some help. It works as expected if I have the BBEdit file named “WebCopy” opened – the file can be Minimized to the Dock, or hidden (Hide App, from the Menu) and it works just fine. But If the file is not open, the script does not create the new file. Here’s the script…

How can I make it create the new BBEdit “WebCopy” file?
The basic idea is to be able to copy some text from one source then append the “WebCopy” doc with text copied from another source.

How 'bout this?


You can also add this line in the write_to_file handler after it has closed access to the file:


The original script does not create a new file because it’s never saved.

There is a difference between a text window and a text document on disk.

While you can create a new text window with the text from the web page, you need to tell BBEdit to save it before the disk file will be created.

Alternatively, as already demonstrated, there’s no need to use BBEdit at all since you can use AppleScript’s file writing commands to append the text.

If you don’t want to keep the file, change the path to temporary items:


Wowzers Jonn8, that’s pretty close. I was wanting to have a double carriage return between the first slection and the subsequent selections, but this is a great help. My main problem was getting the document there from the start. I was able to do so only if I had the “WebCopy” doc opened. Many thanks…

Here’s some more code that does what I think you originally wanted:


Thanks Camelot, saving the document was something else I wasn’t aware of. I was trying to create a file with selections from different sources into one readable file. e.g., If I visit webpage A, I can copy the selected text into a file, then append that file with text selected from webpage B, C, D, … with a double carriage return between the subsequent selections.

This seems to be working quite well…

Many thanks to jonn8 and Camelot.