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.