• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Copying the path of files selected in Finder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copying the path of files selected in Finder


  • Subject: Re: Copying the path of files selected in Finder
  • From: Yvan KOENIG <email@hidden>
  • Date: Sat, 29 Apr 2017 12:18:51 +0200

I would made some changes because on my system - and I'm not the only one - hidden files are always visible.
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






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Copying the path of files selected in Finder
      • From: Jean-Christophe Helary <email@hidden>
    • Re: Copying the path of files selected in Finder
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Copying the path of files selected in Finder (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Copying the path of files selected in Finder
  • Next by Date: Re: Copying the path of files selected in Finder
  • Previous by thread: Copying the path of files selected in Finder
  • Next by thread: Re: Copying the path of files selected in Finder
  • Index(es):
    • Date
    • Thread