try
tell application "Finder"
set theFinderSelection to selection as alias list
if length of theFinderSelection ≥ 1 then
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, linefeed}
set pathList to theFinderSelection as text
set AppleScript's text item delimiters to oldTIDS
set nameList to change "^.+:" into "" in pathList with regexp
set nameList to splittext nameList using linefeed
repeat with i from 1 to (length of theFinderSelection)
set name of item i of theFinderSelection to item i of nameList
end repeat
else
error "No items were selected in the Finder!"
end if
end tell
on error e number n
set e to e & return & return & "Num: " & n
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try