on drop theObject drag info dragInfo
-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- Get a list of the data types on the pasteboard
set dataTypes to types of pasteboard of dragInfo
-- Currently, we are only interested if there are "files names" on the pasteboard
if "file names" is in dataTypes then
-- This is a mechanism to tell the pasteboard which type of data we want when we access the "contents" of the pasteboard.
set preferred type of pasteboard of dragInfo to "file names"
-- Get the list of files dropped on the object form the pasteboard
set thePaths to contents of pasteboard of dragInfo
end if
tell application "Finder"
set thefile to (POSIX file of thePaths as alias)
display dialog thefile
end tell
end drop
When I try the Script, I’ve got an Error in the ‘Finder’ Part. It can’t make an alias to the File i’ve dropped. Can somebody help me?
You can convert the list of POSIX paths into a alias list
on drop theObject drag info dragInfo
-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-- Get a list of the data types on the pasteboard
set dataTypes to types of pasteboard of dragInfo
-- Currently, we are only interested if there are "files names" on the pasteboard
if "file names" is in dataTypes then
-- This is a mechanism to tell the pasteboard which type of data we want when we access the "contents" of the pasteboard.
set preferred type of pasteboard of dragInfo to "file names"
-- Get the list of files dropped on the object form the pasteboard
set thePaths to contents of pasteboard of dragInfo
end if
set aliasList to {}
repeat with aPath in thePaths
set end of aliasList to POSIX file aPath as alias
end repeat
end drop