• 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: "Path to" a file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Path to" a file


  • Subject: Re: "Path to" a file
  • From: Jon Pugh <email@hidden>
  • Date: Mon, 6 Aug 2001 21:58:51 -0700

At 9:56 PM -0400 8/6/2001, Greg Back wrote:
>I am trying to write a simple script to be run out of OSA menu. The script
>will get the path to the file selected in the Finder and paste it to the
>clipboard.

Here's my beefed up version. It has an option to display the path differently by holding down the command key.

Without Command key:

"Magneto:System Folder:Finder"

With the Command key:

Magneto
System Folder
Finder

Of course, now I've copied and pasted over my script which was in the clipboard. Luckily, I have complete control over the situation and can copy it again. ;)

Jon

-- Script "Copy Path" by Jon Pugh
-- Free for use by all
-- ToDo: Add zone and server info for remote files using "alias information" from Jon's Commands.

global optionDown

on run
set optionDown to (keys pressed) contains "Command" -- Requires Jons Commands
set cursor to watch cursor -- Requires Jons Commands
set ans to ""
tell application "Finder"
repeat with x in selection
if ans is "" then
set ans to my pathOf(x)
else
set ans to ans & return & my pathOf(x)
end if
end repeat
end tell
set the clipboard to ans
end run

on pathOf(anItem)
try
tell application "Finder"
if class of anItem is alias file then
set anItem to (original item of anItem)
end if
end tell
if optionDown then
return colons2returns(anItem as string)
else
return "\"" & anItem & "\""
end if
on error errs number errn
display dialog ("Error 3" & errs & "2 (" & errn as string) & ") trying to handle " & (anItem as string)
return ""
end try
end pathOf

on colons2returns(p)
set AppleScript's text item delimiters to ":"
set l to text items of p
set indent to 0
repeat with i in l
repeat indent times
set contents of i to " " & i
end repeat
set indent to indent + 1
end repeat
set AppleScript's text item delimiters to return
set l to (l as string) & return
set AppleScript's text item delimiters to {}
return l
end colons2returns


References: 
 >"Path to" a file (From: "Greg Back" <email@hidden>)

  • Prev by Date: Re: Folder Action Problem
  • Next by Date: Re: move folder & copy image ? (newbie)
  • Previous by thread: Re: "Path to" a file
  • Next by thread: Re: "Path to" a file
  • Index(es):
    • Date
    • Thread