How to set up a user-defined command for a python script

Hi. A bit of a rookie question here. Can't find a thread that helps me out. This one is the closest I've found.

I would like to launch a custom Python-script I've created, and I want to launch it with the selected files and folders as the input for it, as if I was drag/dropping those files onto the script in Director Opus itself.

I have set up something similar before as a command, like this:
"C:\Software\ReNamer\ReNamer.exe" {allfilepath}

But I can't figure out how to do the same thing for my python script.
How should I make the command to launch the .pyw-script in a folder on my C:\ drive?

Thanks in advance for any help :slight_smile:

Probably needs to look like this:

"C:\Software\python\python.exe" C:\python-script.pyw {allfilepath}

Ah thanks, I think this is working.
When I tried it with another script it is, but with mine it just shuts down. Although it works fine when I launch it in other ways. So there has to be some issues when launching my script too. Always more issues :slight_smile:

In case someone else is looking for this, here's my final result:
I created a .bat-file with this in it:

@echo off
"C:\Users\[USERNAME]\AppData\Local\Programs\Python\Python310\python.exe" "C:\Path\To\Script\ScriptName.pyw" %*

Of course, the path to your python.exe may vary.

And for the command in Directory Opus (v11), I run this:

"C:\Path\To\Bat\BatName.bat" {allfilepath}

This works for my case. I can now drag/drop or hotkey the script with a command from Dopus. I had to update the script to contain absolute paths to files that works from a relative location when running the script itself by double-clicking or drag/dropping onto the script rather than like this with a command, but now it all works.

The bat file shouldn’t be needed. If you need a command prompt to open, setting the button’s function type to MS-DOS Batch Function will do that (and generates a bat file automatically, behind the scenes).

1 Like