Applescript that uses Droppeditems doesn't work on Big Sur pls help fix..

Hi I have this applescript working on BigSur Mac. Basically it makes me choose an image file from the file open dialog box and then copies the image's dimensions/file name into the Mac's clipboard (html format).

I want this functionality on an image file that is dropped on the applescript app's icon. Can anyone please help me write the droppeditem applescript that works in BigSur? Thanks!

Working code:
====
set this_file to (choose file) as «class furl»
try

tell application "Image Events"
launch
set this_image to open this_file
copy the dimensions of this_image to {H_res, V_res}
copy the name of this_image to originalname
close this_image
end tell

set myvar to originalname
set the clipboard to "src=\"" & myvar & "\"" & " width=\"" & H_res & "\"" & " width=\"" & V_res & "\""

end try
====


You can do this using an open handler. For example:

Code Block
on open (droppedFiles)
repeat with f in droppedFiles
set thisFile to contents of f
display dialog nameForFile(thisFile) buttons {"OK"} default button "OK"
end repeat
end open


This script just shows the file name in a dialog [1], but you should be able to combine that with your exist code to achieve your final goal.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Using this function to get the file name:

Code Block
on nameForFile(thisFile)
set filePath to thisFile as string
set text item delimiters to ":"
set fileName to text item -1 of filePath
return fileName
end nameForFile

Applescript that uses Droppeditems doesn't work on Big Sur pls help fix..
 
 
Q