I skimmed through this other topic and hoped that by now something like this script would work.
set r to ""
set t to "test"
tell application "Finder" to set f to make new clipping at desktop to r
open for access alias f with write permission
write t to alias f
close access alias f
.and that AppleScript would figure out what and where to write in the clipping when open for access.
But, of course, it doesn’t work.
Can I make a clipping using only AppleScript?
If I get the format right, I guess I could use something like.
.which I’ve used for com.apple.metadata:kMDItemWhereFroms already.
In the thread which you gave the link, Nigel Garvey posted a script doing the job (2009-04-24 08:08:51 pm).
As creating clippings require the creation of a resource fork, Nigel’s script requires the availability of the OSAX named Satimage.osax.
I want to do without any osax. I have to carefully reread Nigel’s post to understand the resource format and then try to use it to pipe the resource to xattr.
-- drag some text to your Desktop and rename the clipping to 'test'
tell application "Finder" to make new clipping at desktop to ""
delay 2
do shell script "xattr -wx com.apple.ResourceFork \"`xattr -px com.apple.ResourceFork ~/Desktop/test.textClipping`\" ~/Desktop/\\ clipping.textClipping"
Yes, but that’s a bit like saying TextEdit can write pictures if it’s given the right data. If you have the right data in a form xattr could use, you could write it directly without xattr using ‘/…namedfork/rsrc’. Carbon resource forks are a sort of black box, only meant to be handled by specific Carbon APIs.
extended attributes are not in a resource fork but just another type of fork in the file system’s object. The proper way to access deprecated resource forks is actually through extended attributes today.
What Shane meant was is that extended attributes and its support for deprecated file system resource forks is something different than Carbon resource files (*.rsrc and *.r files), which is a file format and not a fork. Carbon resources are binary files but with a simple structure as Nigel has shown how easily it can be decoded.