Wonder why my script doesn't run

As a newbie with regards to script I have tried to create a script that changes 'text-months' to months in digits

so, like the below

from: bla bla bla text - 30January 2013.txt
from: bla bla bla text-30January 2013.txt
from: bla bla bla text 30January 2013.txt
from: bla bla bla text -30January 2013.txt
from: bla bla bla text - 3January 2013.txt
from: bla bla bla text-3January 2013.txt
from: bla bla bla text 3January 2013.txt
from: bla bla bla text -3January 2013.txt
to
from: bla bla bla text-30-01-2013.txt
from: bla bla bla text-03-01-2013.txt

this taking 2 languages into account.

(januar[iy])|(februar[iy])|(ma(rch|art))|(april)|(mei|may)|(jun[ie])|(jul[iy])|(augustu?s?)|september|(o[ck]tober)|(november)|(december)

Opus doesn't report an error, but the script doesn't work, one way or the other.

Note: I have script that works fine and used that one as a base.
Only the pattern strings and replacement strings I changed, crossing my fingers it would work.

Hope anybody help me out here.

=

[code]Rename PATTERN="" TO=""
@script vbscript
Option Explicit
Function Rename_GetNewName ( strFileName, strFilePath, _
fIsFolder, strOldName, ByRef strNewName )

 dim re37
 set re37 = new RegExp
 re37.Pattern = "[\s\-]\s?(\d\d)\s?(januar[iy]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re38
 set re38 = new RegExp
 re38.Pattern = "[\s\-]\s?(\d)\s?(januar[iy]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re39
 set re39 = new RegExp
 re39.Pattern = "[\s\-]\s?(\d\d)\s?(februar[iy]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re40
 set re40 = new RegExp
 re40.Pattern = "[\s\-]\s?(\d)\s?(februar[iy]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re41
 set re41 = new RegExp
 re41.Pattern = "[\s\-]\s?(\d\d)\s?(ma(rch|art?))\s?([12][09]\d{2})\.(\w{3,4})"
 dim re42
 set re42 = new RegExp
 re42.Pattern = "[\s\-]\s?(\d)\s?(ma(rch|art?))\s?([12][09]\d{2})\.(\w{3,4})"
 dim re43
 set re43 = new RegExp
 re43.Pattern = "[\s\-]\s?(\d\d)\s?(april?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re44
 set re44 = new RegExp
 re44.Pattern = "[\s\-]\s?(\d)\s?(april?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re45
 set re45 = new RegExp
 re45.Pattern = "[\s\-]\s?(\d\d)\s?(mei|may?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re46
 set re46 = new RegExp
 re46.Pattern ="[\s\-]\s?(\d)\s?(mei|may?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re47
 set re47 = new RegExp
 re47.Pattern = "[\s\-]\s?(\d\d)\s?(jun[ie]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re48
 set re48 = new RegExp
 re48.Pattern = "[\s\-]\s?(\d)\s?(jun[ie]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re49
 set re49 = new RegExp
 re49.Pattern = "[\s\-]\s?(\d\d)\s?(jul[ie]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re50
 set re50 = new RegExp
 re50.Pattern = "[\s\-]\s?(\d)\s?(jul[ie]?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re51
 set re51 = new RegExp
 re51.Pattern = "[\s\-]\s?(\d\d)\s?(augustu?s??)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re52
 set re52 = new RegExp
 re52.Pattern = "[\s\-]\s?(\d)\s?(augustu?s??)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re53
 set re53 = new RegExp
 re53.Pattern = "[\s\-]\s?(\d\d)\s?(september?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re54
 set re54 = new RegExp
 re54.Pattern = "[\s\-]\s?(\d)\s?(september?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re55
 set re55 = new RegExp
 re55.Pattern = "[\s\-]\s?(\d\d)\s?(o[ck]tober?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re56
 set re56 = new RegExp
 re56.Pattern = "[\s\-]\s?(\d)\s?(o[ck]tober?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re57
 set re57 = new RegExp
 re57.Pattern = "[\s\-]\s?(\d\d)\s?(november?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re58
 set re58 = new RegExp
 re58.Pattern = "[\s\-]\s?(\d)\s?(november?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re59
 set re59 = new RegExp
 re59.Pattern = "[\s\-]\s?(\d\d)\s?(december?)\s?([12][09]\d{2})\.(\w{3,4})"
 dim re60
 set re60 = new RegExp
 re60.Pattern = "[\s\-]\s?(\d)\s?(december?)\s?([12][09]\d{2})\.(\w{3,4})"
If (re37.Test(strFileName)) Then
       strNewName = re37.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re38.Test(strFileName)) Then
       strNewName = re38.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re39.Test(strFileName)) Then
       strNewName = re39.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re40.Test(strFileName)) Then
       strNewName = re40.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re41.Test(strFileName)) Then
       strNewName = re41.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re42.Test(strFileName)) Then
       strNewName = re42.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re43.Test(strFileName)) Then
       strNewName = re43.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re44.Test(strFileName)) Then
       strNewName = re44.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re45.Test(strFileName)) Then
       strNewName = re45.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re46.Test(strFileName)) Then
       strNewName = re46.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re47.Test(strFileName)) Then
       strNewName = re47.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re48.Test(strFileName)) Then
       strNewName = re48.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re49.Test(strFileName)) Then
       strNewName = re49.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re50.Test(strFileName)) Then
       strNewName = re50.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re51.Test(strFileName)) Then
       strNewName = re51.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re52.Test(strFileName)) Then
       strNewName = re52.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re53.Test(strFileName)) Then
       strNewName = re53.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re54.Test(strFileName)) Then
       strNewName = re54.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re55.Test(strFileName)) Then
       strNewName = re55.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re56.Test(strFileName)) Then
       strNewName = re56.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re57.Test(strFileName)) Then
       strNewName = re57.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re58.Test(strFileName)) Then
       strNewName = re58.Replace(strFileName, "-0$1-01-$3.$4")
ElseIf (re59.Test(strFileName)) Then
       strNewName = re59.Replace(strFileName, "-$1-01-$3.$4")
ElseIf (re60.Test(strFileName)) Then
       strNewName = re60.Replace(strFileName, "-0$1-01-$3.$4")
End if

End Function[/code]

=
Thanks

The best thing you can do is simplify your script as much as possible (e.g. so it only does one or two of the 60 cases it currently does), and then see if that works.

If it does not work even when simplified, then you should use DOpus.Output to print some debugging information to work out what is going on when the script is run. You can print out variables to find out what their values are, or you can print out strings which tell you which branches of the code get run, and which do not.

That will usually let you work out which line of code is going wrong, and then you can focus on why it's failing, or ask for help with that specific line, where people can help much quicker.

Thanks! This script is about 24 renames, I copied it from another script that ended with 36 so in the other script I continued with 37 and so on.
Anyway, I cut it down to 4 renames only, but it still doesn't run.
I have spent the last 1,5 hour to figure out how I get DOpus.Output in, but I don't know how to do that.
Gave it various tries, looking at other scrips where this function was used.
Yes, I also did look into the Helpfile, I gave up... :frowning:
If you've got a spare moment, could you pls assist?

=

What do you mean "doesn't run" ? Do you get an error message?

The script is supposed to rename files. Nothing happens when I run it. Opus does not log script errors either. If it would, I could work on it. The basis was/is a perfectly working script. FWIW: I noticed that the differences in the patterns of the working script, they all start with (.+)followed with further regex.This (.+) is missing in the new patterns. Wonder though whether that has anything to do with it.

The script log will show any errors that occur.

Successfully initialized 'vbscript' engine
Script started successfully
Script completed

However, nothing changes.

So there are no errors, which suggests its your regex. As Leo suggested, simplify your script and use DOpus.Output to print out diagnostics to track down where it's going wrong.

See my post a bit earlier about Dopus.Output.

I don't understand sorry. Are you saying you don't know where to use it, or how to use it?

Both to be honest. I gave it a serious try to figure this out, went over many sites to check for examples, checked out F1, tried some but had to let it go. Remember, the very first line of this thread. It shd be in the script somewhere (presumably at the bottom?) but how no clue as to how it should read.

=

It looks like VBScript RegEx is case sensitive by default. If I try your script with "bla bla bla text - 30january 2013" it seems to work (or at least to do something).

You can make it case insensitive by setting the IgnoreCase property on the regex object to True (e.g. re37.IgnoreCase = True
)

Many thanks indeed!

It worked out fine now, like the below

//
'januar[iy] double-digit regex
dim re37
set re37 = new RegExp
re37.IgnoreCase = True
re37.Pattern = "[\s-]\s?(\d\d)\s?(januar[iy]?)\s?([12][09]\d{2}).(\w{3,4})"

// etc ///

results:
bla bla bla text-26-09-2013.txt
bla bla bla text-29-03-2016.txt
bla bla bla text-29-11-2013.txt
bla bla bla text-30-01-2013.txt
bla bla bla text -01-06-2013.txt
bla bla bla text -01-08-2014.txt

Maybe I should do a little finetuning to remove the spaces in front of the hyphens (last two lines), but I got it working now.
Finally.

Thanks again!