Python: How to use it in Rename Dialog?

I can't figure out how to use Python for the Rename Dialog in DOpus.
The only two scripting engine languages listed there a JScript and VBScript.

I already registered the client by executing:
win32comext\axscript\client\pyscript.py
from Python 3.7 libraries. But it does not yet do the trick.

What must be done to use Python in the Rename Dialog?
And if that would work - does anyone have an example how to implement

Function OnGetNewName(ByRef getNewNameData)
(...)
End Function

as an equivantent in Python then so that getNewNameData can be accessed?

Thanks :slight_smile:

No ideas?
Is this not possible after all?

Have you seen this thread?

I think it's possible but you're making life more difficult for yourself if you don't use VBScript or JScript, since they are what everything was designed around and are known to work; what all the examples are written in, and what almost everyone who can help you on the forum knows.

As they're built-in to Windows, they're also the ones that make sense if you want to share things with other people (else you have to tell them to download and install a particular version of a language in addition to the script).

All the scripting languages are very similar, at least the way they are used within Opus, which tends to be fairly simple scripts.. It's easier to learn a slightly different syntax than it is to work out how to get a non-standard (in this context) language to work instead of the other two.

You can use other languages if you want to, but you're largely on your own if you do.

That is kind of true. However, if the person in question find that he/she can use whatever
language they're used to (especially if he/she has little to no knowledge of JS/VB), they can leverage
that to make up for it..several-folds, depending on their knowledge and how "well-behaved"
said language is in a host.

However, the syntax used for each language's interaction with DOpus can be bewildering to say the least.
There has been (some) success with both python and perl, but other than that..

IMO/IME, once you know one scripting language it's trivial to pick up another (at least for basic stuff, which is all you'll usually be using with Opus).

Learning the first language is the hard part! :slight_smile:

True that.. However, I just thought of another reason.
Depending on what they're intending to do, both Python and Perl has extensive libraries
that can be used from within the scripting environment. This is probably the main reason
as JScript is rather limited.
DO alleviates the issue quite a bit with a few of its exposed objects, but..

I've mentioned the rich library thing in a previous thread.

I think the better, richer way forward would be to have DOups ofer a REST interface such that ANY programming language could interact with it. Eliminate the dependency on this silly Microsoft Active Scripting late 80's junk. Leave the existing interface for VBScript nuts and JScript fans.

Better too late than never...

Below is a Title Case rename script I use for some music files.
For MP3s old name is "*.mp3" and new name is "{mp3track} {mp3title}.mp3", uses "All words with capital letters" setting.
Handles "(xxx cover)" name postfix and parts in "()".

art1=['the','a','an']

prepos1 = [
'a','abaft','aboard','about','above','absent','across','afore','after','against','along','alongside','amid','amidst','among','amongst','an','anenst','apropos','apud','around','as','aside','astride',
'at','athwart','atop','barring','before','behind','below','beneath','beside','besides','between','beyond','but','by','circa','concerning','despite','down','during','except','excluding','failing',
'following','for','forenenst','from','given','in','including','inside','into','lest','like','mid','midst','minus','modulo','near','next','notwithstanding',"o'",'of','off','on','onto','opposite',
'out','outside','over','pace','past','per','plus','pro','qua','regarding','round','sans','save','since','than','through','thru','throughout','thruout','till','times','to','toward','towards',
'under','underneath','unlike','until','unto','up','upon','versus','via','vis-a-vis','with','within','without','worth']

conj1 = ['and','but','for','or','nor','to','so','yet']

to1 = ['to']

name1 = ['de','von']

alllower=art1 + prepos1 + conj1 + to1 + name1


def OnGetNewName ( GetNewNameData ):

	old_name = GetNewNameData.newname
	name_tab = old_name.split()

	for i,w in enumerate(name_tab[2:-1]):
	    if w[0] == '(' or w[-1] == ')':
	        next        
	    else:
	        if w.lower() in alllower:	        
                    name_tab[i+2]=w.lower()

	if name_tab[-1] == 'Cover)':
            name_tab[-1] = 'cover)'		
	if name_tab[0][0] == '0':
	    name_tab[0] = name_tab[0][1:]

	if len(name_tab[0]) == 1:
	    name_tab[0] = '0'+name_tab[0]
	return ' '.join(name_tab)