Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Open text clipping files in TextEdit System
My first hint: very ugly, but offered here in the hope that something more beautiful will come of it.

MacOS X's Finder creates these rather strange .textClipping files when you drag text into one of its windows. As far as I can make out, only Finder can read them, either in its Inspector or in a Finder window that pops up when you click on the .textClipping file. I guess they're a legacy from Classic Mac, where presumably there are other apps that can read them (SimpleText?). You can't copy and paste their contents from Finder, so my task was to find a way of extracting their content into TextEdit.

Read the rest of the article for the workaround solution...

The trick is that the text is concealed (from normal MacOS X apps and command line utilities) in a resource fork. As well as the plain text, there's some binary junk in there too. So here's my quick and dirty command line fix. Open a Terminal and type:
 % cd directory/with/clipping/
% strings < Some.textClipping/rsrc > /tmp/xxx && open -e /tmp/xxx
Wow. This is ugly in at least a couple of ways. First, you shouldn't have to redirect the file into strings (the utility that strips out the binary junk); strings should just take the name of the file as a parameter. But Darwin strings complains that "it is not an object file". Duh!

The filename/rsrc hack to get to the resource fork has been discussed here before (thankfully, because that's how I learned about it). This in itself isn't ugly, although the use of resource forks in general and in this case in particular are, erm, somewhat... well, perhaps we'd better not get into that here.

Transferring the data through /tmp/xxx is a particularly nasty hack. I'd love to be able to do "open -e -", which would be the standard UNIX way of treating stdin (ie the data passed through the pipe) as the file to open. Alas Darwin open isn't written that way.

Well, there it is. I'd love someone to step forward and tell me it's all completely unnecessary because I've overlooked something!
    •    
  • Currently 3.83 / 5
  You rated: 4 / 5 (6 votes cast)
 
[19,763 views]  

Open text clipping files in TextEdit | 15 comments | Create New Account
Click here to return to the 'Open text clipping files in TextEdit' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Drag n Drop
Authored by: nicksay on Apr 01, '02 09:22:26AM

Just drag the .textClipping into the body of a TextEdit document and the text is automatically converted, inserted at the cursor point, and highlighted. This also works for Microsoft Word, Project Builder, Stickies, etc ...



[ Reply to This | # ]
I think....
Authored by: leenoble_uk on Apr 01, '02 09:25:44AM

I may have missed something by skim reading that hint but, have you tried just dragging the clipping icon (unopened) from the desktop into an open document?
I use this technique a lot and it even works between classic applications and X applications. I've dragged source code from web pages to the desktop and then into dreamweaver, no problems.
Also, just occurred to me, haven't tried it out but when you have the clipping open in the Finder what services are available? If textedit is available it will probably allow you to create a new document using the information displayed. I have recently started using services, its a habit I'd like to break in to. Like in omniweb I found some code on oreillynet, hit Command-A, OmniWeb->Services->TextEdit->New Note, Save note as codefoo.php



[ Reply to This | # ]
ya beat me
Authored by: leenoble_uk on Apr 01, '02 09:28:07AM

I shouldn't have been so comprehensive there, ya beat me to it while I was typing. :)



[ Reply to This | # ]
Why not from the Finder...
Authored by: robg on Apr 01, '02 10:56:11AM

So you can drag it into an existing document, but why can't you open it by dragging and dropping it onto TextEdit itself? Or even more annoying, why can't you copy and paste the contents of a clipping file? I know you can drag and drop it, but sometimes that requires manipulating open windows.

Clippings seem like an excellent idea that got about 80% implemented then shipped ;-).

-rob.



[ Reply to This | # ]
Why not from the Finder...
Authored by: DavidRavenMoon on Apr 01, '02 10:09:06PM

Tex-Edit Plus can open clipping files. You have to go to File > Open Any... You can't drag them onto its icon though.

I wonder why Apple removed the ability to copy text from a clipping?

I've been using Tex-Edit as a replacement to SimpleText for a while, and have it set to open all my .txt files in OS X. It does a lot of cool things!



[ Reply to This | # ]
kerpow!
Authored by: mervTormel on Apr 01, '02 11:34:10AM

well, in playing with the, er, um, rez fork solution,
i discovered one thing that you don't wan't to do:

% mv foo/rsrc foo

kernel panic" lockmgr: locking against myself

ouch

although, you can, benignly:

% mv foo/rsrc bar



[ Reply to This | # ]
Attention to Detail
Authored by: seedy on Apr 01, '02 12:30:39PM

Try this: Get Info on that file and select preview from the drop-down in the GI box. Not bad for a half-baked format.

Noticed something else as well, which is that when I use Zingg!(if Zingg! hasn't been a tip yet, it should be) to open the file it doesn't offer Textedit as a choice, but does offer Appleworks (I have version 5) as a choice. So maybe it's a special format.

Or you could stop dragging text, which is the simplest way. In Mozilla you can select and copy any text and it will paste into Textedit and look very nice. I've been using X since September, have swiped acres of text off my browsers (job hunting, Unix tips, etc.) and didn't even know you could drag text.

Maybe I'm advertising my ignorance, but on the other hand the process worked just fine.

I keep a Textedit link in the Dock for that very reason. And I keep a folder in the Dock called Tempfiles for just this sort of random stuff. Makes it easy to keep the desktop pattern in view.


Or we could try to find out why there's no "Open With Application" choice in the Get Info window.



[ Reply to This | # ]
Another Solution
Authored by: twehr on Apr 01, '02 08:04:13PM
clipEdit 2.25 will open the clipping and then allow you to export it as a plain text file.

Unfortunately, you cannot drag and drop a clipping onto clipEdit. It doesn't open it. You have to open it manually from within clipEdit.

clipEdit will also open graphic clippings and allow you to export in various formats.

[ Reply to This | # ]
Use TextEdit Services rather than copy/paste
Authored by: jmil on Apr 01, '02 10:50:36PM

I agree that .textClippings need to be implemented better. However, in applications that have services enabled, you may be happy to find out that TextEdit has services that come along with it.

Select text and/or graphics in OmniWeb
Select OmniWeb -> Services -> TextEdit -> Open Selection

It will create a new document with the text and graphics displayed exactly as they were on the webpage. This is great. Services need to be emphasized more. The document will be saved as .rtfd (a package with the images hidden inside)! Fantastic. Unfortunately, "Open File" doesn't seem to work for me. I guess you are supposed to use it from the Finder, but the Finder doesn't have services enabled on my 10.1.3 machine. Ugh. Although services do work in SNAX (the alternative to finder.app), the TextEdit Open File service doesn't work correctly for textClippings (I
just get a blank document). Please let Apple know of these inconsistencies. I'm looking forward for 10.2.



[ Reply to This | # ]
um, maybe simplest...
Authored by: mike666 on Apr 02, '02 02:14:15AM

...would be to get info on a clipping, go to the Open with Application section, choose TextEdit or your favorite text app, then hit the Change All button? Works like a dream.



[ Reply to This | # ]
um, maybe simplest...
Authored by: osxpounder on Apr 02, '02 05:34:28PM

"... works like a dream ...."

No, it doesn't. Did you even bother to try before you wrote this? Any .textclipping file's Info panel will not show an option to choose an Application for opening the file--as anyone who honestly tried would know.



[ Reply to This | # ]
Summary of Responses (and Thanks)
Authored by: el bid on Apr 02, '02 04:51:36AM

OK, as the author of a dumb "tip" that has raised more questions than it answered, and inspired a very simple answer that shows I'd overlooked the bleedin' obvious, it falls to me, I think, to make amends by summing up the responses here.

The simple answer from nicksay (also spotted by leenoble_uk) is that although you can't open a .textClipping file in TextEdit, you can always drag the file into an already opened TextEdit file. This is obviously The Way To Do It (tm) and is a complete response to the plea in my tip for "something more beautiful". Nice one, nicksay.

Nevertheless, you have to ask (as some of you have) why this strangely unorthogonal behaviour (a file TextEdit can't see to open but can see as a drag item)? Clearly .textClipping dragation is a deep feature of the Cocoa text framework, but resource fork visibility isn't present in the NeXTStep-inherited FileOpen behaviour. My guess is that Apple wants to shift away from this kind or (or indeed any) use of resource forks in future.

leenoble_uk asks: "just occurred to me, haven't tried it out but when you have the clipping open in the Finder what services are available?" The answer of course is "none" -- notoriously Finder is a Carbon app that offers no services at all (as jmil has noticed), just at the point where they would be most useful. This, IMHO, is the one to bug Apple about.

In Apple's defence, seedy offers: "Try this: Get Info on that file and select preview from the drop-down in the GI box. Not bad for a half-baked format." Well, of course the same Preview shows up directly in Finder when you highlight the filename in Columns view. But the "half-baked" thing about this is that although you can read the text like this, you can't, for example, highlight a selection of it and copy that off to somewhere else.

I'm a little puzzled by mike666's "solution": "..to get info on a clipping, go to the Open with Application section, choose TextEdit or your favorite text app, then hit the Change All button? Works like a dream."

Alas, .textClippings files don't offer an "Open with Application" section in the Finder's "Show Info". So, yes, it does work exactly like most of my dreams -- ie, not at all. :-)

Perhaps mike666 has some magic shareware extension installed that allows this. Can we have more news on this?

Thanks very much to everybody who responded to this, er, "tip", especially of course to nicksay and leenoble_uk. In the light of their masterly trumping of the trick I suppose I could just pretend mine was an April Fool's prank. But it wasn't, and I've learnt a lot.

--
el bid



[ Reply to This | # ]
textclippings still crummy
Authored by: osxpounder on Oct 07, '04 06:28:04PM

After all this time, dragged text is still hobbled. What a shame. ".textclipping" files are crummy compared to .txt files; the OS should be revised so that dragged and dropped text in Finder becomes a .txt file.

Another drawback to the Preview [Get Info] option is that you can't scroll the text. I just grabbed a few hundred words and dragged them off the browser onto the Desktop. Preview only shows the first 10 lines.

And, yes, mike666 was totally wrong and obviously didn't actually try opening the file in TextEdit. Maybe mike dreamed it.

---
--
osxpounder



[ Reply to This | # ]
textclippings still crummy
Authored by: jiclark on Oct 07, '04 07:27:01PM
After all this time, dragged text is still hobbled.
Hobbled? How so? I believe clipping files (in Panther) are finally back to where they were in the last version of OS 9.x...

I have no issue with the idea that you should be able to have the option of dragging blocks of text to create .txt files, but as clipping files, I'm perfectly happy with the way they work now. The fact that you can open one, hit cmd-c, close it and go paste somewhere else; or alternatively, drop the clipping directly into a document... I personally love that behavior, and use it almost daily.

[ Reply to This | # ]
Updated Command Line
Authored by: bengber on Apr 20, '09 09:50:56AM
Probably didn't work in 2002, but the command line in 10.4 is much simpler:

strings myFile.textClipping/rsrc | open -f

[ Reply to This | # ]