Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Insert a file or folder path in a text editor or text area System
If you want to insert the path to a file or folder into a text editor or text entry area, here's a shortcut.

Simply type the words choose file or choose folder and select those words. Then in the Services Menu, select Services -> Get Result of AppleScript (or use the very handy shortcut, Shift-Command-8). The Script Editor will launch and start bouncing on the dock. Bring it to the front, and the file or folder dialog navigation selection box will show. Navigate to the file or folder you're interested in, and click Choose.

When you do so, the full path appears in the text editor or text entry area in place of the text you originally typed and selected.

[robg adds: Since this hint uses the Services menu, it will only work in Cocoa applications, and some Carbon applications that have been coded to support Services.]
    •    
  • Currently 1.67 / 5
  You rated: 2 / 5 (3 votes cast)
 
[4,601 views]  

Insert a file or folder path in a text editor or text area | 9 comments | Create New Account
Click here to return to the 'Insert a file or folder path in a text editor or text area' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Insert a file or folder path in a text editor or text area
Authored by: hsinha on Feb 14, '05 11:46:11AM
You can also use a very useful utility "copypath" from Bergen Street Software. It installs a contextual menu in Finder and allows one to copy the path of a particular file or folder, which then be pasted anywhere. It allows both Unix path and HFS path options.

http://www.bergenstreetsoftware.com/index.html

[ Reply to This | # ]

Insert a file or folder path in a text editor or text area
Authored by: mark hunte on Feb 14, '05 01:12:19PM

The other interesting thing is that this also shows hidden files..

---
mh



[ Reply to This | # ]
Insert a file or folder path in a text editor or text area
Authored by: geekman on Feb 14, '05 06:23:28PM
To show invisibles while choosing a file or folder using the services technique change the text to
choose file with invisibles

---
Creative Smarts ||
geekman

[ Reply to This | # ]

Insert a file or folder path in a text editor or text area
Authored by: patlaj on Feb 14, '05 02:48:14PM
To get a path with slashes instead of colons, just revise to this:
posix path of choose file
or
posix path of choose folder


[ Reply to This | # ]
Insert a file or folder path in a text editor or text area
Authored by: geekman on Feb 14, '05 06:31:16PM
I found that POSIX only works with brackets around the choose file or choose folder command. ie
posix path of (choose file)
or
posix path of (choose folder)

---
Creative Smarts ||
geekman

[ Reply to This | # ]

Insert a file or folder path in a text editor or text area
Authored by: jao on Feb 14, '05 04:08:32PM

There's also a copy path service available at

http://www.scotlandsoftware.com/products/systemservices/



[ Reply to This | # ]
Insert a file or folder path in a text editor or text area
Authored by: dogboy on Feb 14, '05 06:58:37PM

If you use Launchbar, you have a couple of other options:
1 Navigate to the file or folder using LB and hit Cmd-C (Copy) when you get there. The path is copied to the clipboard.
2 If the item is already highlighted in the Finder, activate Launchbar, hit Cmd-G to get Finder selection and then hit Cmd-C to copy to the clipboard.



[ Reply to This | # ]
... Or use an Applescript droplet
Authored by: cnotarianni on Feb 15, '05 09:41:25AM
You ca use an Applescript like this: drag one or more files on top of it and volià!

(* 
Copyright © Notarianni Carlo
*)

choose file with prompt "Choose the file to get path"
open (result as list)


on open (thelist)
	(*
	open receives a list of documents that were dragged onto the droplet's icon, and passes 
	the document names one at a time to the handle routine. 
	*)
	set TempClipboard to ""
	repeat with theNames in thelist
		tell application "Finder"
			set TempPath to theNames as text
			--copy TempPath & "" to TempPath
		end tell
		if TempClipboard is "" then
			set TempClipboard to TempPath
		else
			set TempClipboard to TempClipboard & (ASCII character 13) & TempPath
		end if
	end repeat
	set the clipboard to TempClipboard
end open


[ Reply to This | # ]
... Or use an Applescript
Authored by: macintron on Feb 16, '05 02:25:29AM
... and save it in your '~/Library/Scripts/' folder

tell application "Finder"
	try
		set frontPath to get selection as alias
		set posixPath to (get POSIX path of frontPath)
		set hfsPath to (frontPath as string)
		
		set theMsg to "Copy path to clipboard: " & return & "POSIX:" & return & posixPath & return & return & "HFS:" & return & hfsPath
		tell me to display dialog theMsg buttons {"POSIX", "HFS", "Cancel"} default button 1
		set userAnswer to button returned of result
		if userAnswer is "POSIX" then
			set the clipboard to the (posixPath as string)
		else if userAnswer is "HFS" then
			set the clipboard to the hfsPath
		end if
	end try
end tell


[ Reply to This | # ]