Right-click option to copy file full path to clipboard

To add an option to Windows Explorer right click menu, which copies a file's (or folder) path to the clipboard is tricky, but easy though.

To do the easiest way, just download and run (double clicking) the following files: copyfilepathtoclip.reg and copyfolderpathtoclip.reg. Or read more to understand better how it works and figure out how to create your very custom right-click shortcuts...

Open the Registry Editor (press Win+R > type regedit > click OK), and create the following key:

HKEY_CLASSES_ROOT\*\shell\Copy as Path\command

The created key will have a value called (Deafult). Double-click it and set the value data to:

cmd.exe /c (echo.|set /p=\"%1\")|clip

You want to end having something like the picture below:

copyfilepathtoclip

And you are done! Just right click any file to see the option Copy as path available.


To do the same for folders, just repeat the process replacing the *  with Folder, like this:

HKEY_CLASSES_ROOT\Folder\shell\Copy as Path\command

A few things you might have noticed at this point, but worth mention:

  • You can repeat the process for any filetype you find under the HKEY_CLASSES_ROOT key (* means all types).
  • In the (Default) command, %1 is the selected file/folder full path.
  • You can use this to call any program with custom parameters, like a compiler such as javac.exe.
  • echo.|set /p=\"%1\" is just a tricky way to do echo %1 without ending with a line-break.
  • the ending |clip (pipe-clip) writes the result of the piped command (echo) to the clipboard.

 

Tags: tweaks, regedit, productivity