Without the changes the script list these visibles hidden files.
# This script gets the POSIX path of the Finder selection.
# If there is no selection, it gets the container.
# If there is 1 selection, it gets the path, without adding a linefeed
# If there are multiple selections, all the paths are on a separate line
# If there is no selection and no container (search window), an alert is displayed
# The result is put into the clipboard and the data can be pasted wherever needed.
# A notification is displayed when the clipboard is available.
# The notification only displays the first selected item.
tell application "Finder"
set _selectedItem to selection
set thePaths to {}
try
if _selectedItem is {} then
set end of thePaths to POSIX path of (insertion location as alias)
else
repeat with anItem in _selectedItem
set aPath to POSIX path of (anItem as text)
tell application "System Events" to set isVisible to (visible of disk item aPath)
if isVisible then
set end of thePaths to aPath
end if
end repeat
end if
set _selectedItem to my recolle(thePaths, linefeed)
set the clipboard to _selectedItem
display notification _selectedItem
on error
display notification with title "Select at least one file in the window."
end try
end tell
#=====
on recolle(l, d)
local oTIDs, t
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
#=====
Even without these changes something is not accurate in the comments :
the notification is able to display two paths - if they aren't more than 46 characters long.
Yvan KOENIG running Sierra 10.12.4 in French (VALLAURIS, France) samedi 29 avril 2017 12:18:18