Inserting and Appending Text with TextSoap
On the surface this seems like a silly, even trivial request, insert a line of text at the top of the file and append a line of text to the bottom of the file. And it is a simple request, until you want to do it in bulk.
Then it becomes a copy/paste nightmare that is woefully inefficient or you get into
for .. each loops and some other variants of shell scripting.
What I wanted to do was add code blocks to top and bottom of several Markdown files so they would be seen as code. Groovy code to be specific with the:
While looking for a reliable solution that could be easily implemented, I caught something in TextSoap. It has an
Insert Action. It’s an insert Before and After action. When no text is selection, the action is performed on the entire block of text. Since TextSoap has a menu bar button, the action can be performed anywhere.
But there is a little more. TextSoap has a Batch File Cleaning function. There you can specify the Cleaner and the files it should act on.
There is also the TextSoap Palette, which is a floating menu of all the TextSoap filters, including all the Custom Cleaners so it can be repeatedly used with any open application.
So what started as shell scripting exercise, turned into a simple two-line insert function within TextSoap that is now available to all applications or could even be run against a series of files. That was pretty handy!