Convert a textclipping file to plain text

While creating a .textclipping file is a easy method to save a selected piece of text, the actual usefulness of a .textclipping is quite limited as it is easily opened in Finder and can be copied and pasted into other apps but it cannot be directly edited and with Ventura. If it is opened with TextEdit, which is the only way Apple provides as a means of conversion to plain text, Unlike a the clean conversion that older versions of TextEdit provided, it now get with the clipping all its formatting code and other stuff that has to be edited out to extract the basic text clipping. Additionally, no other Apps that I have found or seen in my research seems to be able to open a .textclipping file other than Finder or TextEdit. This also means that it cannot be directly shared with other OS’s.

So for a long time I have spent many hours trying to find a simple solution to properly convert a .textclipping file in to a plain text file with no success until now. While there are a number of scripted solutions to this using shell scripts, Applescript, or Automator none have worked as they all seem to rely of depreciated or commands no longer available in their original form in Ventura. So with the assistance of some of the new AI tools and figuring out what to ask them, I finally stumbled on a simple Automator solution that actually works with the result being a converted plain text file with the original file name in the same location that the original file was located. It is also capable of simultaneously creating a HTML file in the same manner. The original Automator script originally created both, but by putting a hashtag (#) in front of the line of code that writes the HTML file I have disabled it as I have no use for the file in HTML format. If you wish to have the HTML file, just delete the hashtag in front of the last line of the shell script in the Automator script.

The script is in the copyable PDF below. First create a new Quick Action in Automator. Add the 2 Automator Actions, from the Action Library. Then the copy and paste the shell script code into the second shell script action deleting what may there

Notes: First, make sure that the shell is set correctly to python3 in the pull down menu. Then be sure the shell script Pass Inputs is set to arguments instead of stdin or the script will not work.

After confirming that it matches the code in the pdf file below, deleting the hashtag in the last line if an HTML file is desired, Save the Quick Action and Give it your desired name. As a Quick Action it will be saved in the right place.

To use, simply select the desired .textclipping file to convert and then from the contextual menu, select the Quick Action you created under the Quick Actions title in the contextual menu.

Here is the PDF
Convert Text Clipping.pdf (395.3 KB)

Here is the copyable shell script code in the Automator Service
Convert Text Clipping script.pdf (18.3 KB)

If you wish to convert it to rich text, TextEdit will do that for you and do that correctly.

I am no longer a programmer and am not familiar with python. So I have no real idea on how this works or how to do any serious modifications. So all I know about it is what is in this topic. Hope you find it useful as I have.

2 Likes

BBEdit will open .textclipping files as plain text which will then save as plain text files. BBEdit is scriptable, and it’s free for basic functionality. I’ve been a licensed user since long before the freemium pricing model, so I have no idea if the ability to open .textclipping files is part of the free version feature set.

3 Likes

Based on my 2nd attempt you are correct. Since I also have a paid version I, like you cannot confirm with the free version will do. The first time I tried it turned a textclipping into hex code. Have no idea why it did that but the second time it worked.

Advantages of the Quick Action service is of not having to add or download a 3rd party app, it is accessible from a contextual menu and does not have to be saved, as it is done automatically saving steps.

You should be able to drag/drop the clipping file onto any text editor window. This will cause its content to be pasted into it, just as if it was on the clipboard.

I just tried it with Emacs and it worked exactly as expected. It also worked with “vi” in a Terminal window and TextEdit (pasted as formatted text into a Rich Text document and as plain text into a plain text document.)

I suspect that this will work on most (if not all) other text editors.

Don’t open the clipping file. Open a new document and drag/drop the clipping onto it.

2 Likes

If you copy the textclipping in Finder and paste it into an App all I get is a file insert as an icon. If I drag the plain text textclipping into an App or open empty App file I get the text and other garbage. However what you indicate is working for me when the textclipping is RTF. In any case the traditional method does requre mutiple steps. With the Quick Action I simply click on the clipping with my magic pad, choose the contextual menu Quick Action and presto, I have a new saved text file with the same file name that I can immediatly open, edit or print. I find this to be a real productivity booster, especially when dealing with mutiple clippings.

I just tried this with the free version BBEdit 12.6.7. Asked BBEdit to OPEN failed as the clipping file was grayed-out. However, just dragging and dropping the clipping into a new BBEdit document (as David suggested) did create text that seems to be editable as I tried changing a word in the text and it was accepted.

Text clippings have always (System 8?) been intended for drag and drop, not as normal openable files. Kind of like web-page-title.webloc files.

1 Like

I’ve always used ClipEdit for this. It is the perfect solution.

ClipEdit (free)

(ClipEdit allows you to open and edit text and picture clippings.)

It is, unfortunately, no longer being further developed. But it is still available for download. It appears to be 32-bit only. It runs perfectly under Mojave, but it may not work in later versions of the Mac OS. The developer, Everyday Software, is still active, so if there is enough demand, maybe they will be willing to update it?

Although not free (at approximately $17.50 US) Jedit Ω tackles this task and many others with ease.

It opens .textClipping files directly and can convert them in place to text files.

I generally use BBEdit for managing text clippings, since it runs 24/7 on my systems – and I usually open .textClipping files in it (or Jedit) using LaunchBar’s Send-To capability.

I also have an AppleScript I wrote many years ago to batch convert .textClipping files to text files in place. This script is dependent upon the Satimage.osax which is obsolete as of Mojave (and I’m still using).

However – I just wrote a new script using AppleScriptObjC which should work on modern versions of macOS.

I can post that if anyone’s interested.

1 Like

Per your request I have added a copyable PDF file of the actual shell script to my original posting as Tidbits does not allow text files to be attached.

1 Like

Per a contributers request I have added a copyable PDF file of the shell script to my posting. Simply open the PDF script file; Copy the contents; and paste it into the the shell script action in Automator. Note the options for the shell script action at the top of the Automator PDF as if not set correctly this script will not properly work.

1 Like