Copy selected finder items names to Clipboard in AppleScript

  1. Ask for Finder items
  2. Get selected Finder items
  3. Run AppleScript

on run {input, parameters}

set selectedItems to input

set fileList to “” — Initialize the fileList variable

repeat with selectedItem in selectedItems

if class of selectedItem is file then

set itemName to name of selectedItem

else if class of selectedItem is alias then

set originalPath to POSIX path of selectedItem

set itemName to (do shell script “basename ” & quoted form of originalPath)

else

set itemName to “” — Handle other cases (e.g., folders) gracefully

end if

if itemName is not “” then — Only add non-empty items to the fileList

set fileList to fileList & itemName & linefeed

end if

end repeat

set the clipboard to fileList as text — Copy the fileList to clipboard

end run