Forums | MacLife
You are not logged in.
#1 2003-10-17 7:25 pm
- lkobzik
- Member
- Registered: 2003-10-17
- Posts: 3
path identification in OS X
Is it possible to identify the path (like a local URL) for a file with a command within OS X, without going into UNIX.
I need to paste the local URL of many pdf files into a reference manager. A command to get the info would make it a lot easier.
Thanks
Les K
Offline
#2 2003-10-17 7:55 pm
Re: path identification in OS X
Save this code as an Application using script editor:
Code:
-- Copyright (C) 2003 Miles
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
on open these_items
try
set z to ""
repeat with i in these_items
activate
set j to (POSIX path of i as string)
set x to AppleScript's text item delimiters
set AppleScript's text item delimiters to " "
set s to every text item of j
set AppleScript's text item delimiters to "%20"
set j to s as string
set AppleScript's text item delimiters to x
if the (count of these_items) is 1 then
set z to "file://" & j
else
set z to z & "file://" & j & return
end if
end repeat
display dialog "Your URLs are in the clipboard." buttons {"Thank You"} default button 1
set the clipboard to z
on error
display dialog "an error occured" buttons "damn" default button 1
end try
end openand then drag files on it.
This code is flawed in that it can only handle filenames containing alphanumeric characters and spaces, but it's a start. I GPLed it just to be a bitch.
Offline
#3 2003-10-18 8:51 am
- lkobzik
- Member
- Registered: 2003-10-17
- Posts: 3
Re: path identification in OS X
Thanks it works like a charm!
les K
Offline
#4 2003-10-18 4:22 pm
- [MA] Flying_Meat
- Member
- From: Frisco?
- Registered: 2001-03-31
- Posts: 8516
Re: path identification in OS X
there is a contextual menu item that will copy the path (of one, or many files) to the clipboard also.
Oddly named CopyPath or something. 
...and watch out for the flying meat!
Offline
#5 2003-10-18 4:34 pm
- dinerfan
- a natural, zesty enterprise

- From: the sunny side
- Registered: 2000-12-31
- Posts: 11093
Re: path identification in OS X
Flying_Meat"]there is a contextual menu item that will copy the path (of one, or many files) to the clipboard also.
Oddly named CopyPath or something.
Yep, CopyPath. Control-click an item and you have your choice of UNIX-style: "/Library/Fonts/Baskerville.dfont"
or HFS-style paths: X:Library:Fonts:Baskerville.dfont
Nice freeware, available here:
http://www.versiontracker.com/dyn/moreinfo/macosx/13672
Offline
#7 2003-10-19 11:05 am
- DevilDuck
- Member
- Registered: 2003-03-24
- Posts: 24
Re: path identification in OS X
Use the Go to Folder in the Go menu in the finder. It tab completes justy like tcsh, and expands ~ as well. The only thing it does not do is accept relative paths, only absolute paths, but for copying the paths, this works great.
Hope it helps
Stef
Offline
#8 2003-10-19 4:39 pm
Re: path identification in OS X
Go to Folder is for entering POSIX-style paths, not getting them out; the only way it could be used for that is the tab-complete. And it does accept relative paths. 
Offline
#9 2003-10-19 8:29 pm
- lkobzik
- Member
- Registered: 2003-10-17
- Posts: 3
Re: path identification in OS X
I have used both the script generously prepared by A boy...Charlie Brown and the CopyPath freeware kindly suggested by the others. Thanks again to both.
It turns out (for my obscure purposes) that the script works better.
Script:
file:///Users/lkobzik/Desktop/2000Grade09A.pdf
CopyPath:
"/Users/lkobzik/Desktop/2000Grade09A.pdf"
When I paste these into the URL of my reference manager software (EndNote), only the Script works with the Go to Link function: That is to say , I can open the file from the reference entry. The CopyPath URL leads to a search by my internet browser, which of course fails.
The CopyPath program's use of the right mouse click is a nice feature, and I guess I could fiddle with the CopyPath URL to make it refer to the local files. For now, I will stick with the quite elegant script, I am very grateful to all for the help,
Les K
Offline
#10 2003-10-19 10:20 pm
Re: path identification in OS X
You can also drag disks, files or folders onto browser windows to get the path.
I'm using Firebird 20031007 just in case anyone's browser has problems doing that.
Offline
#12 2003-10-20 7:02 pm
- DevilDuck
- Member
- Registered: 2003-03-24
- Posts: 24
Re: path identification in OS X
You are quite mistaken A Boy Named Charlie Brown, the Go To Folder does not accept relative paths. Try typing
../
in the text field, this is a relative path that should go to the /Users directory if in your home directory, yet it does not, it gives an error: Folder could not be found. So I do not know what you are talking about, but it does NOT accept relative paths.
Offline
#13 2003-10-20 8:00 pm
Re: path identification in OS X
Hmm... that's disappointing. If you are in any folder, though, you can type the name of a subfolder. i.e. in your home folder enter "Desktop". This path is relative to the current folder, not the root. Thus, Go to Folder accepts absolute paths ("/Applications/"), home-relative paths ("~/Documents/Homework") and some relative paths ("Desktop/junk") but not all POSIX-style relative paths ("../../../etc/").
Hey cool, we disagree, but we're both right. 
Offline
