Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How do I copy/paste a directory path?

I use a fair bit of web and 3D programs.

Some of the code I use requires that path to any given file be typed into the code...

for instance

/Users/myname/01 DWS/01BusinessDocuments/ImportantInfo/TPSReports/Taxes.doc

Is there an easy way for me to not have to type that entire line in. I would rather cut and paste it. On a PC this is easy, navigate to the file and address/directory path is shown in the finder window, copy and paste it.

The best way I've found to do it on a MAC is navigate to the file. Hit command+i on the keyboard and then highlight the path from the info panel. However, this omits the actual name of the file which I then have to type in. Seems like I should be able to snag the entire address somehow.

Any ideas? Would love to be able to do this, at least without having to type in the name of the file.

Thanks.

-D

Macbook Pro, Mac OS X (10.6.4), Intel Core 2 Duo 2.33, RAM 3GBs

Posted on Jul 23, 2010 4:18 PM

Reply
Question marked as Best reply

Posted on Jul 23, 2010 4:21 PM

Select the file and run the following from the AppleScript Editor in the /Applications/Utilities/ folder:

tell application "Finder"
POSIX path of (selection as alias)
end tell

(52929)
6 replies

Jul 23, 2010 4:35 PM in response to Niel

That's pretty slick.

Is there any way to store that command in Apple Script so don't have to type it every time I need it?

Also-

I tried setting the AppleScript Editor to a hotkey. OSX would accept it but when I hit the hot key combo which was cmd+o... nothing happened. Any thoughts?

Thanks

Jul 23, 2010 6:52 PM in response to Fraky

Hey... I completely underestimated AppleScript... wow. What a fun thing that is. I had never used it before.

OK... here's what I've came up with as a solution for me. Maybe this will work for someone else too.

I'm looking for a super fast easy way to cut copy and paste the path of any given file

Here's the code I'm using. Niel... I took your code and added to it a touch.

tell application "Finder"
set currentPath to (POSIX path of (selection as alias))
set the clipboard to currentPath
end tell

This copies the path of 1 selected file to the clipboard.

I saved this script as an application. I was hoping to hotkey it as an application (sft cmdc) but whenever I tried to set it up in my hotkey preferences my system preferences would crash?

I read that you can leave the app on the desktop and drop your selected file onto it... this would cause the application to run.

I didn't want to leave this app as an icon on my desktop and have to drop the file onto it to get it to work- as my software GUI takes up all that real-estate. I didn't want to have to move windows around and then drop the icon, and then move the windows back... you get the idea.

I have the magic mouse and I've always used use MagicPrefs to give it some more functionality. You can set certain swipes of the fingers on the mouse to run applications. I set a 1 finger swipe to the right to run the above application. It worked like a charm!

So now all I have to do to copy the path of any file is: Navigate to the file> Click on it> Swipe my mouse finger to the right and then cmd+v away.

Thanks for you help guys. Any ideas why system preferences was crashing as I was trying to set this ApplesScript application to run when hotkeyed? I would rather have this app work as a hotkey but the mouse swipe isn't bad.

-Thanks

-Drew

How do I copy/paste a directory path?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.