I enquired in the reddit regex forum and they tell me that regex alone can't do it.
I imagine that it must be quite a common problem.
thank you
maybe save as a RTF? without the D
ok, this turned out to be more interesting that I thought, solution if you have MS Word:
- Copy-paste document to Word, or open it using Word
- Save as RTF
- Done, a RTF without images.
Even if you could use a regex to "remove" the images, they'd still remain in the file -- just not referenced or displayed. I agree with @hello, simplest route would be to use an app to either open the document then "Save As..." an RTF or, if it can't open RTFD, copy'n'paste the content from something that can and then "Save As..." RTF.
Another option would be to pull the text file directly out of the package -- I'm not sure how easy that would be though.
This might help you @ronald.
Building on @Nige_S's suggestion, it's easier to pull images out of the RTFD "package"...
On a Mac the RTFD
"file" is actually just a container. So as an example here's a test RTFD showing in TextEdit:
As you can see the file is Test.rtfd
and it's just some text followed by an image with more text, another image etc.
If you go to that file in Finder, right click on it and then choose "Show Package Contents", Finder will then display this:
In other words, the container Test.rtfd
has within it a file called TXT.rtf
and two image files called IMG_1609.jpg
and Another Image.png
.
If you then just delete the two image files so, in Finder, you see this:
and you then go back to TextEdit and open the file Test.rtfd
this is what you get:
In other words, the images have gone and all you're left with is the text.
Alternatively, just copy the package's TXT.rtf
to wherever you need and you've got the text only!
In terms of automating this I really am unsure - maybe some brighter spark than me can give you a hand...
Being pedantic -- the references to the images are still there, it just can't find the images to display them. That may or may not matter, depending on how forgiving @ronald's software is of such borkage...
A quick way of sorting this is to "Open" the "TXT.RTF" file in TextEdit and then save it again, which seems to remove the broken references.
thank you very much @hello @Nige_S and @tiffle for finding a solution, and double thanks for @tiffle for your detailed and elegant post.
Excellent solution to my problem.
Have a go with this one -- it rewrites the file as rtf, removing the broken references in the process.
As posted it will work on a Finder selection, saving the resulting files to the same directory as the originals and with the originals' name except with an .rtf
extension. Change hotkey to suit, etc, etc.
Even if the workflow isn't exactly as you want you should be able to use the "Execute Shell Script" action to build your own version.
RTFD to RTF.kmmacros (2.9 KB)
Works perfectly. You are a genius !
Genius indeed