A Windows Explorer Gem


I just tripped into this little gem and just couldn’t let this go without telling somebody, ‘cause I could have used this little feature 15 years ago!

Ever had to find a file on your machine with the only purpose to determine the absolute location to that file so that you could write some code that makes the path relative, etc., etc.?

Until today, I would typically find the file in Windows Explorer, then quickly hit Alt-D to put the focus in the address bar of the explorer window, which selects the full path to the directory of the file, like so:

image

Then I can easily Ctrl-C to copy, and away I go.

That works pretty well, but when I want the actual name of the file included in that path, I have to go paste the copied path, then type in the ‘\’, and then type in the name of the file ( assuming I could remember the name! ).

Well, no longer!

Hold the Shift key down while right-clicking on a file or directory. Go ahead, try it. Do you see anything different?

Here’s the context menu when I right click *without* holding the shift key over the mscorlib.dll file:

image

And here’s the context menu with the Shift key down while right-clicking:

image

Yes, “Copy as path”!!!!

Learn something new everyday….. Smile

Enjoy!

Cameron

Comments (13)

  1. Brad says:

    Holy crap.  This is so full of awesome it's ridiculous.  Thanks!

  2. fatherjack says:

    Is there a gem like this that lists the directory contents to a text file, like old windows versions used to have a toolbar icon for?

  3. I'm not aware of one, but clearly, that doesn't mean it doesn't exist! 🙂

  4. gerleim says:

    @fatherjack: command line (run cmd)

    dir /b > files.txt

    /b for bare format, /s for subdirs

  5. Good Tip says:

    That's great, but now I want to know how one can tweak the registry to get the "copy as path" command to be displayed without holding down the Shift key. Anyone?

  6. Jimk says:

    I used to build pathes in xp in the start bar.  Missed it in win7 thanks

  7. W G says:

    That feature was available 15 years ago (well, almost).  It was the SendToX power toy for Win95.  I made a c# app that mimics the path copying part of the power toy which copies the path(s) of selected files/directories to the clipboard without needing to press the shift key.  It's simple enough to do during a coffee break.  Create a new C# Windows forms app, delete the form, and replace the entry method with this:

        [STAThread]
    
        private static void Main(string[] args) {
    
            if (args.Length > 0) {
    
                string value = string.Join(Environment.NewLine, args);
    
                Clipboard.SetText(value);
    
            }
    
        }
    

    build the app, then create a shortcut to the .exe in your 'Send To' directory (%APPDATA%MicrosoftWindowsSendTo in Win7, %USERPROFILE%SendTo in XP).  I used the power toy's shortcut name of 'Clipboard as Name', as I was already accustomed to that.  Now, when you right-click on a file/directory, you can select Send to -> Clipboard as Name and the path(s) will be copied to the clipboard.  No shift key needed.

    The SendToX power toy had a couple of other options that I haven't recreated, such as send to command line and send to clipboard as contents, which would put the contents of a file into the clipboard.  You can see the details in the TechNet archive: technet.microsoft.com/…/cc751394.aspx.

  8. learning_to_code says:

    Usually I open the file in Notepad++ and use the CopyFilePath To Clipboard. I am still on XP, so this won't work for me.

  9. jader3rd says:

    This is awesome. I know I will be making use of that. The other one I use is if no items in the explorer window are selected is that I press Shift and then the context menu will have "Open command window here", which is also very useful.

  10. TimMasterson says:

    Thanks, I didn't know about the alt-D

  11. David Candy says:

    To copy a directory selext all files the use Copy As Path. As CopyAsPath is a shell extension rather than a static verb the shift key can't be disabled. However Open Command Prompt Here the shift key can be disabled by deleting the "Extended" named value from HKEY_CLASSES_ROOTDirectoryshellcmd

  12. Siavash Mortazavi says:

    OMG! thanks, it's really helpful.

    😀

  13. Mark says:

    What about getting the absolute path on a network mapped path.  The copy as copies the mapped drive letter.