Using Python scripts in Windows Explorer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ben Sizer

    #1

    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

  • richard.charts@gmail.com

    #2
    Re: Using Python scripts in Windows Explorer


    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.

    Comment

    • MC

      #3
      Re: Using Python scripts in Windows Explorer

      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


      Comment

      • Thomas Heller

        #4
        Re: Using Python scripts in Windows Explorer

        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

        Comment

        • Gabriel Genellina

          #5
          Re: Using Python scripts in Windows Explorer

          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.
          >
          >Unfortunatel y, 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

          Comment

          • Ben Sizer

            #6
            Re: Using Python scripts in Windows Explorer

            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.p y' 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

            Comment

            • Ben Sizer

              #7
              Re: Using Python scripts in Windows Explorer

              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

              Comment

              • Ant

                #8
                Re: Using Python scripts in Windows Explorer

                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\pyt hon.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.

                Comment

                • Gabriel Genellina

                  #9
                  Re: Using Python scripts in Windows Explorer

                  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.
                  >
                  >Unfortunatel y, 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

                  Comment

                  Working...