6 Replies Latest reply: Jul 23, 2010 6:52 PM by Fraky
Fraky Level 1 Level 1 (5 points)
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/01DWS/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
  • Niel Level 10 Level 10 (272,125 points)
    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)
  • CT Level 6 Level 6 (16,645 points)
    Another way: drag the file into a Terminal window.

    And this: http://www.macosxhints.com/article.php?story=20071018002311820

    charlie
  • Fraky Level 1 Level 1 (5 points)
    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
  • Niel Level 10 Level 10 (272,125 points)
    Save the following as an application and put it in the Dock or the Finder's toolbar:

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

    (52931)
  • Fraky Level 1 Level 1 (5 points)
    Thanks guys. Both solutions worked well.

    But the terminal window... that was lightning fast and no need to type anything.
  • Fraky Level 1 Level 1 (5 points)
    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 (sftcmdc) 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