"Whenever you can, share. You never know who all will be able to see far away standing upon your shoulders!"
I write mainly on topics related to science and technology.
Sometimes, I create tools and animation.
So often we need the location (path) of the files or folders which we have selected in the Windows explorer, e.g. for documentation, or for creating/modifying shortcuts etc.
Generally, in Windows, it's a two step process:
I've simplified this task for myself using Python, and given below are the steps to do it.
Using the mechanism described below, we'll add couple of entries to the right-click context-menu, clicking on which will:
We get a context-menu entry like this:
Not only this makes this task faster, using this, we can get paths to multiple files (or folders) in one go.
Let's look at the three steps below.
Save it with the name
Path_to_Selected_File.pyw, and get its full path - we'll need it in the next step.
You may give it any name.
Also, we are using
.pyw for silent processing.
Save the following in a
.reg file and run it so that these are added to the Windows registry.
Note that we are adding the context menu item for both files and folders.
In the code below, use the Python
exe path that exists on your Windows, as well as the full path to the script we saved above.
The above will handle only single selections.
It, actually, can handle multiple selections - but it will show multiple boxes which is annoying, and only the path of the last item will be in the clipboard in the end.
To handle multiple selections, we can do this:
sendTofolder by typing
shell:sendToin the explorer address bar.
After this, this action item will be visible in the
Send To group in the context menu.
This will allow us to select multiple items and get their paths into the clipboard.