- Ask for Finder items
- Get selected Finder items
- 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