Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is there shortcut to convert a selection of text into a plain text document sort of like textclipping?

I love how you can just grab a selection of text from the web, and drag it into a folder. The problem is that this text gets saved as a .textclipping files which is more or less useless. I was wondering if there was a way I can do the same thing (drag text into a folder) but have it save as a .txt or .doc or something. Of course, I could just open TextEditor, but I don't want to have to do that every single time. Maybe like an automator scripts or something?

MacBook Pro, Mac OS X (10.6.8), Installing 10.9

Posted on May 5, 2015 3:17 PM

Reply
4 replies

Mar 12, 2017 9:04 PM in response to ReedP

Thank you very, VERY much for this helpful fix. I have hundreds of reference clippings that have accumulated over the years, but they are not consistently searchable by Spotlight. This script converts them beautifully. I named a folder "TextClipping Conversion, Drop Here" on my desktop, and will drag all new clippings there.

I hope Apple will eventually make this conversion unnecessary by allowing edits, and indexing everything with Spotlight -- but this will be a big improvement in the meantime. I will mention this to other users; thanks for your time and effort!

Mar 12, 2017 9:07 PM in response to Jacques Rioux

Thank you very, VERY much for this helpful fix. I have hundreds of reference clippings that have accumulated over the years, but they are not consistently searchable by Spotlight. This script converts them beautifully. I named a folder "TextClipping Conversion, Drop Here" on my desktop, and will drag all new clippings there.

I hope Apple will eventually make this conversion unnecessary by allowing edits, and indexing everything with Spotlight -- but this will be a big improvement in the meantime. Thanks for your time and effort!
< Note: Sorry for the double post below; my reply went to the wrong recipient on the first pass, and i don't see a way to edit/delete here. >

May 6, 2015 3:26 PM in response to ReedP

Hi,


It's possible with Automator and a shell script :


How to create folder actions using Automator :


1. Create a Folder Action

To begin, launch Automator, When the application launches, select “Folder Action” from the list of available Automator workflow types, click on the "Choose" button.


At the top of the workflow, you will see a “Folder Action receives files and folders added to ...” Using the drop-down menu, select “Other,” and navigate to and select a folder on your system that you wish to attach the folder action to.


Next, we’ll begin building the workflow that will get triggered when files are added to the folder containing the action.


Find and drag the "Run Shell Script" actions to the workflow section of Automator (the right-hand palette, underneath the folder selection):

In the "Shell" pop-up menu, select the "/usr/bin/python" shell.

In “Pass input” pop-up menu, select "as arguments"

Clear the default script in the action.

Copy/paste this script in the action :


import sys, os
from Carbon.File import FSGetResourceForkName
from Carbon.Files import fsRdPerm
from Carbon import Res
ext = '.rtf' ### or use '.txt' if you want a plain text file

if (ext == '.txt'):
    tType='utf8'
else: tType='RTF '
for f in sys.argv[1:]:
    if f.endswith('.textClipping'):
        try:
            resF = Res.FSOpenResourceFile(f, FSGetResourceForkName(),fsRdPerm)
            Res.UseResFile(resF)
            t = (Res.Get1Resource(tType, 256)).data
            Res.CloseResFile(resF)
            tempF = os.path.splitext(f)[0]
            outF = tempF + ext; i=1
            while (os.path.exists(outF)):
                outF = tempF + str(i) + ext; i += 1

            fo = open(outF,'w')
            try:
                fo.write(t)
                os.remove(f)
            finally: fo.close()
        except: continue


You can change '.rtf' to '.txt' in fifth line of this script, if you want a plain text file.


Select File > Save menu, and in the save dialog, enter the name of the workflow that you wish to reference this folder action by in the future.

Quit Automator


That’s all.

----


Here are some information about the script :

If it's a textClipping file , the script get the data in the resource fork of the file, and write the data to a new RTF file (same name as the textClipping file), If this succeeded, the script delete the textClipping file.

May 6, 2015 3:29 PM in response to Jacques Rioux

Thanks for the script! For anyone else reading this solved my problem. However, I already had some .textClipping files the folder that I applied the Automator workflow to, and even when dragging them to a different location and dragging back in sometimes the conversion didn't work. Pulling quotes directly off the web and dragging them into the folder worked like a charm, and is exactly what I needed. I would never have been able to figure that out on my own. That whole 'resource fork' stuff is way beyond me.

Is there shortcut to convert a selection of text into a plain text document sort of like textclipping?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.