473,249 Members | 1,552 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,249 software developers and data experts.

Using Python scripts in Windows Explorer

I'd like to be able to drag a file onto a Python script in Windows
Explorer, or send that file to the script via the Send To context-menu
option, so I can then process that file via sys.argc.

Unfortunately, I can't drag items onto the Python script, because
Windows doesn't recognise that the script is executable (unless I
double-click it, upon which it runs as usual, without the command line
parameter of course) and won't set it as a drop target. And it won't
even appear in the Send To menu after the usual steps are taken to get
it there.

I then tried to wrap it in a batch file, but encounter a problem, where
that batch file is able to execute the Python file if I double-click
the batch file, but if I drag a file onto it it says it can no longer
find the Python script.

Are there any simple and workable solutions for this sort of thing?

--
Ben Sizer

Oct 20 '06 #1
8 4051

Ben Sizer wrote:
I'd like to be able to drag a file onto a Python script in Windows
Explorer, or send that file to the script via the Send To context-menu
option, so I can then process that file via sys.argc.

Unfortunately, I can't drag items onto the Python script, because
Windows doesn't recognise that the script is executable (unless I
double-click it, upon which it runs as usual, without the command line
parameter of course) and won't set it as a drop target. And it won't
even appear in the Send To menu after the usual steps are taken to get
it there.

I then tried to wrap it in a batch file, but encounter a problem, where
that batch file is able to execute the Python file if I double-click
the batch file, but if I drag a file onto it it says it can no longer
find the Python script.

Are there any simple and workable solutions for this sort of thing?

--
Ben Sizer
I didn't even know you could do that at all, but my suggestiong would
be compile the python script into an executable and try that.
If you get it working, update here as I am interested in your solution.

Oct 20 '06 #2
MC
Hi!

I use this little batch:

@echo off
cd \dev\python
viewarg.py %*

I copy/paste the batch-file on the desktop, like icon.
Then, from Win-explorer, drag_and_drop & copy_and_paste run OK.

--
@-salutations

Michel Claveau
Oct 20 '06 #3
Ben Sizer schrieb:
I'd like to be able to drag a file onto a Python script in Windows
Explorer, or send that file to the script via the Send To context-menu
option, so I can then process that file via sys.argc.

Unfortunately, I can't drag items onto the Python script, because
Windows doesn't recognise that the script is executable (unless I
double-click it, upon which it runs as usual, without the command line
parameter of course) and won't set it as a drop target. And it won't
even appear in the Send To menu after the usual steps are taken to get
it there.

I then tried to wrap it in a batch file, but encounter a problem, where
that batch file is able to execute the Python file if I double-click
the batch file, but if I drag a file onto it it says it can no longer
find the Python script.

Are there any simple and workable solutions for this sort of thing?
I think you can create a shortcut to the Python script, and then drag files on it.

Thomas

Oct 20 '06 #4
At Friday 20/10/2006 12:20, Ben Sizer wrote:
>I'd like to be able to drag a file onto a Python script in Windows
Explorer, or send that file to the script via the Send To context-menu
option, so I can then process that file via sys.argc.

Unfortunately, I can't drag items onto the Python script, because
Windows doesn't recognise that the script is executable (unless I
double-click it, upon which it runs as usual, without the command line
parameter of course)
Create a shortcut and drop the file over it.
>and won't set it as a drop target. And it won't
even appear in the Send To menu after the usual steps are taken to get
it there.
Same here: put a shortcut to the script on your SendTo folder
(wherever it resides)
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
Oct 20 '06 #5
MC wrote:
I use this little batch:

@echo off
cd \dev\python
viewarg.py %*
I try that (with viewarg.py renamed, obviously), and get this error:

"'defines.py' is not recognized as an internal or external command,
operable program or batch file."

defines.py is in the same directory as the batch file, but cannot be
executed like this. Double-clicking on it works, as expected.

--
Ben Sizer

Oct 23 '06 #6
Gabriel Genellina wrote:
At Friday 20/10/2006 12:20, Ben Sizer wrote:
I'd like to be able to drag a file onto a Python script in Windows
Explorer, or send that file to the script via the Send To context-menu
option, so I can then process that file via sys.argc.

Unfortunately, I can't drag items onto the Python script, because
Windows doesn't recognise that the script is executable (unless I
double-click it, upon which it runs as usual, without the command line
parameter of course)

Create a shortcut and drop the file over it.
Doesn't work; the mouse cursor changes to the "not permitted" sign and
when you release the mouse, nothing happens.
and won't set it as a drop target. And it won't
even appear in the Send To menu after the usual steps are taken to get
it there.

Same here: put a shortcut to the script on your SendTo folder
(wherever it resides)
That is what I meant by 'the usual steps'. :) It doesn't work.

--
Ben Sizer

Oct 23 '06 #7
Ant
Ben Sizer wrote:
Create a shortcut and drop the file over it.
....
That is what I meant by 'the usual steps'. :) It doesn't work.
Alter the target of the shortcut to something like:

C:\Python25\python.exe C:\0\sort_test.py

and drag and drop should work, with the filename of the dragged file
being sent as a script argument.

Oct 23 '06 #8
At Monday 23/10/2006 07:53, Ben Sizer wrote:
>I'd like to be able to drag a file onto a Python script in Windows
>Explorer, or send that file to the script via the Send To context-menu
>option, so I can then process that file via sys.argc.
>
>Unfortunately, I can't drag items onto the Python script, because
>Windows doesn't recognise that the script is executable (unless I
>double-click it, upon which it runs as usual, without the command line
>parameter of course)
Create a shortcut and drop the file over it.

Doesn't work; the mouse cursor changes to the "not permitted" sign and
when you release the mouse, nothing happens.
@WorksForMe (on XPSP2 with local administrator rights)
(but I've used such shortcuts even on Windows 98)
Perhaps it's some configuration, or you don't have enough permission
to do that.
>and won't set it as a drop target. And it won't
>even appear in the Send To menu after the usual steps are taken to get
>it there.
Same here: put a shortcut to the script on your SendTo folder
(wherever it resides)

That is what I meant by 'the usual steps'. :) It doesn't work.
Same as above! I think you should ask on a Windows newsgroup.
--
Gabriel Genellina
Softlab SRL

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
Oct 23 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Sam | last post by:
Only 2 weeks messing around with it ( thanks to programs like SYNCHRONEX and BITORRENT ), and already trying to create windows ( the paths are just too long for me to want to type them ). After...
1
by: Chris Cottee | last post by:
Hi, I am trying to extend PAMIE (sourceforge project to functionally test web sites using com and python) and I wondered if anyone had done this sort of thing before and had any pointers. My main...
35
by: Michael Kearns | last post by:
I've been using python to write a simple 'launcher' for one of our Java applications for quite a while now. I recently updated it to use python 2.4, and all seemed well. Today, one of my...
23
by: anton.vredegoor | last post by:
Here's my situation: I'm typing this in a public library on a computer with OS windows 2000 server. I can run Internet explorer, word, excel and powerpoint, that's it. Maybe java, but it seems...
12
by: rurpy | last post by:
Is there an effcient way (more so than cgi) of using Python with Microsoft IIS? Something equivalent to Perl-ISAPI?
1
by: DropIn | last post by:
Sheesh! I was doing research on using batch files as drop targets when I came across a python discussion thread on this site with the same topic. I thought I would share what I had learned (the...
34
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH...
18
by: W. Watson | last post by:
What do I download to use Python with MX XP Pro on an ASUS 4 year old motherboard? I would guess a good book source for starters would be the O'Reilly book. Wayne T. Watson (Watson Adventures,...
9
by: korean_dave | last post by:
From command Prompt, i type in a script, "tryme.py". This, instead, brings up PythonWin editor and Interactive Window. Path variable is "C:\Python24". (I need Python 2.4 installed, not 2.5) ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.