I'm trying to create a simple script to copy the filepath of a selected file (in windows explorer) to the clipboard in python.
I've been looking at pyperclip
and tkinter
but I'm unsure how exactly to proceed.
The askopenfilename
in tkinter
seems promising, but I'd like to select the files outside python and then call the script through the windows context menu.
EDIT:
I want to create a script which can alter a local filepath to a network path when I copy it using the windows context menu (right click).
e.g. when right-clicking on my file C:\Users\LocalUser\test.txt
in windows explorer I want to add a dropdown option to copy the filepath, but change the directory to e.g. D:\Users\LocalUser\test.txt
.
I'm thinking of adding the context menu option by adding a new key in RegEdit and adding a shortcut to the python script in Computer\HKEY_CLASSES_ROOT\*\shell
, but in order to do so, I need to be able to copy add the filepath to my clipboard first.