Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ambrosia7177

macrumors 68020
Original poster
Feb 6, 2016
2,079
397
Does anyone here have experience using the text editor called BBEdit?

I have a repetitive task that I would like to automate, and I am wondering if it could be done using BBEdit?
 
BBEdit is a text editing app that can be used to write scripts. If you don’t already know scripting languages, you may be better off using Automator or AppleScript editor.
 
BBEdit is a text editing app that can be used to write scripts. If you don’t already know scripting languages, you may be better off using Automator or AppleScript editor.

Here is what I am trying to do..

I need to take some HTML files and replace some of the code based on keywords.

For starters, if I could open up a blank HTML file in BBEdit, click a button, and it would simply do a "Find and Replace" on the defined keywords that would be a real time saver.

Of course, being able to just paste in a URL or file name, and click a "Process" button, and having it do the "find and replace" and then saving the file would be even better.

Having an automation script like this would be a real time saver for me as I need to do tis a couple times a day, however, if I have to send a few months learning a new scripting language, then I'm thinking the return wouldn't be worth it.

Hope that makes sense, and that maybe there is an easy solution out there.

(BTW, I have a fair amount of programming experience. Yet while understand coding logic, I am not a professional script writer!)

Thanks!
 
If you know programming, BASH scripting, python, etc should come pretty easy to you.

I found this on Stack Overflow, seems promising. Using a for loop and sed, you should be able to run a script that inspects all files in a directory, searches for a string or url, and replaces it. If your routine is as simple as defining a string to remove and another to insert, you could create a script to search for *.html in a given directory, and pop up a dialog to prompt for the strings.

Bash uses a lot of conventions you should already be familiar with, you should be able to pick it up fairly quickly.

BBEdit is a fine program. You can open multiple files, create a search and replace parameter, and use a couple of keystrokes to run it for each file. The app is free for 30 days with full features, then pro features are disabled unless you buy a license. May be worth a shot to download it and try it out.
 
BBEdit supports AppleScript automation very thoroughly. See Chapter 13 of the BBEdit User manual.

You can save an AppleScript to the BBEdit Scripts folder and it will appear as a menu item in the Script menu (fancy scroll-S icon) so that you can call it by selecting it from the menu.

To automate the find-and-replace command, for example, you'd do something like

Code:
tell application "BBEdit"

    activate

    open find window

    replace "text to be replaced" using "desired replacement text" searching in text 1 of
document 1options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}

end tell
 
Last edited:
BBEdit supports AppleScript automation very thoroughly. See Chapter 13 of the BBEdit User manual.

You can save an AppleScript to the BBEdit Scripts folder and it will appear as a menu item in the Script menu (fancy scroll-S icon) so that you can call it by selecting it from the menu.

To automate the find-and-replace command, for example, you'd do something like

Code:
tell application "BBEdit"

    activate

    open find window

    replace "text to be replaced" using "desired replacement text" searching in text 1 of
document 1options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}

end tell

Is BBEdit worth the $50 they charge?
 
Is BBEdit worth the $50 they charge?
It depends on your tastes and exactly what you are wanting, but I think it is. I probably run it more than any other application, using it to manage RubyMotion projects, edit and run shell scripts, HTML, Markdown, property lists, etc. As already mentioned, it has extensive AppleScript support, and is pretty much a text editing Swiss Army knife.

It is also worth noting that after BBEdit's 30-day free trial expires, it will continue to run with features similar to TextWrangler (which has been sunsetted), so even if you don't want the full version, you will still have a decent programming editor.
 
  • Like
Reactions: Ambrosia7177
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.