I have an image view to drop files on to.
I want it to switch to the icon of the dropped file.
I already have enough script to detect its type:
set dropKind to (kind of (POSIX file (droppedItem) as alias))
I just need the image that represents it.
It’s not possible to get the icon of a file with AppleScript, but it is with Objective-C
Add to your project the following file’s:
IEFFileIcon.h
IEFFileIcon.m
Now you can call the method in your AppleScript like this:
set thePath to POSIX path of (path to desktop)
-- item 1 = posix path to the file
-- item 2 = the image view to set the image
call method "getImageForPosixPath:placeInImageView:" with parameters {thePath, image view 1 of window 1}
Hope it helps,
ief2