Skip to content

Instantly share code, notes, and snippets.

@WirlyWirly
Last active November 1, 2020 07:09
Show Gist options
  • Save WirlyWirly/5b3635a4b70a08499543c375752b393f to your computer and use it in GitHub Desktop.
Save WirlyWirly/5b3635a4b70a08499543c375752b393f to your computer and use it in GitHub Desktop.
How to create drag and drop functionality for python files
If you're on windows, have python installed, and would like to be able to drag-and-drop files on-top of python scripts (.py/.pyw files), this will show you how to set that up.
! Make sure python is in your path otherwise this won't work
1) Create a shortcut for the .py file: Hold alt while you drag the file
2) Right-click on the shortcut and open its properties
3) In the 'Target' field, add the word 'Python' (no quotes) to the very beggining of the line: Make sure you don't edit/delete the part that was already there. Press OK.
ex: python "C:\Path\to\Python_file.py"
4) Drag-and-drop your items on-top of this shortcut and the script will process them
Optionally, you can add this shortcut it to your send-to folder, which will give you access to it from your context menu.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment