use framework "Foundation" use framework "AppKit" use scripting additions set fromPosix to "/Users/ionah/Desktop/111/" set toPosix to "/Users/ionah/Desktop/222/" set imageData to (current application's NSWorkspace's sharedWorkspace's iconForFile:fromPosix) (current application's NSWorkspace's sharedWorkspace()'s setIcon:imageData forFile:toPosix options:0) (current application's NSWorkspace's sharedWorkspace's noteFileSystemChanged:toPosix)
When copying a custom icon with the setIcon method, the result is not what is expected:
The pasted icon is always different from the original in terms of colors & shadow.
In late system 9, I had a script that was able to read an write the “icns” resource (number -16455 or -16496).
Is it possible to do this or something similar with AppleScriptObjC?
I can get the icon data from the pasteboard but can’t find how to read/write the resource from/to a file or folder.
use framework "Foundation" use framework "AppKit" set POSIXPath to "/Users/ionah/Desktop/333.icns" set thePasteboard to current application's NSPasteboard's generalPasteboard() set theData to thePasteboard's dataForType:"com.apple.icns" theData's writeToFile:POSIXPath atomically:true