Reputation: 6949
I have a simple script that displays filenames
import os
path = "C:\\temp\\somefiles\\"
theFiles = os.listdir(path)
for f in theFiles:
print(f)
bak.txt gwen.bat spoon_01.jpg spoon_02.jpg
So far so good. Instead of hardcoding the pathname, I want to be able to drag & drop the files I want to process onto a minimalist desktop widget. What are my options with Python?
Upvotes: 1
Views: 3304
Reputation: 4231
As per the comments, in windows you can drag a file onto a .py file and it will execute with the files in the sys.argv variable
import sys
theFiles = sys.argv[1:] #argv[0] is the script itself.
for f in theFiles:
print(f)
input("Press Any Key to Continue")
Putting your .py file in the windows 'SendTo' directory allows you to do this from the right-click menu
Upvotes: 2