For the life of me I can’t figure out how to get the file name for items dropped on a droplet.
Can someone guide me on this?
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
on open dropped_items
repeat with theItem in dropped_items
-- HOW DO I GET THE FILE NAME OF theItem???
end repeat
end open
The name of a file is a property controlled by either the Finder or System Events.
At the bottom, I’ll show how you can use them to get all the properties of a file.
But here is how you would get the name of a collection of dropped items. The commands inside the finder tell block get the name of each item and append it to a list. After the repeat loop ends, it converts the list into text and displays it in a dialogue.
use scripting additions
-- take dropped files
on open dropped_items
set nameList to {}
repeat with theItem in dropped_items
tell application "Finder"
set nom to name of theItem
set end of nameList to nom
end tell
end repeat
set text item delimiters to linefeed
set paras to nameList as text
display dialog paras
end open
Here are two examples of how to get Finder and System Events properties from a file.
set theFile to choose file
tell application "Finder"
properties of theFile
end tell
set theFile to choose file
tell application "System Events"
properties of theFile
end tell