REGEX removing dots and other things

I have a file name like this

This is what I would like to do.
1- To remove all the dots before the year
2- then to remove the MATCH after the year

And achieve something like this

I have been able to do this with two REGEX from examples here but is it possible to do it in one? Thanks.

There are several threads about this, please try the search.
This thread for example:

[Regex help : replace dots by spaces)

Script to perform multiple Regular Expressions is a good way to do this.

Thank you leo, that helps a lot.
However as you said VBScript doesn't have the same syntax
I have this

how I should put it in VBScript?
Seems # doesn't work in VBScript.

My second RegEx works perfeclty.

The # is an Opusism.

VBScript's rename object has a Global flag which does the same thing (in this context). The example script sets it so if you've based yours on that then you should be able to simply remove the #

re.Global = True ' All matches will be replaced, not just the first match.

I tried as you said and it doesn't work. I added the line to your script like this

	re.Global = True ' All matches will be replaced, not just the first match.
	re.Pattern = "(.*)\.(.*)([0-9])([0-9])([0-9])([0-9])(.*)"
	strNameOnly = re.Replace(strNameOnly, "$1 $2$3$4$5$6$7")

Sorry, ignore my last post. Yes I saw the line
re.Global = True
but it doesn't work I have this

re.Pattern = "(.*)\.(.*)([0-9])([0-9])([0-9])([0-9])(.*)"
strNameOnly = re.Replace(strNameOnly, "$1 $2$3$4$5$6$7")

and it's executed only once! Only one dot is removed.

It's probably because the regexp is matching the four digits as well, and there's only one match for them.

BTW you could simplify that regexp a lot as it's got way more groups (brackets) than it really needs.

You could simplify things even more and use VBScript's string find & replace functions to remove the dots instead. :slight_smile:

Well the pattern is correct under Dopus, I put

and it works and removes all the dots before the date.

I have to learn VBScript. I want to remove only the dots before the date. Is it that simple with string find & replace functions? For the moment RegEx is more simple for me.

The # in Opus tells it to keep applying the regex until the string stops changing. It'd be like a loop in VBScript.

Are you just trying to avoid removing the dot that's for the file extension? The example script handles that another way by removing the extension and then putting it back again after applying the other changes. Much easier as then you can just replace all dots with spaces etc. without worrying about the extension at all.

No its not about the extensions. There could be several dots after the date just in the file name. I want to keep them.

Use this in the script:

	Dim strNameOnlyOld
		strNameOnlyOld = strNameOnly
		re.Pattern = "(.*)\.(.*[0-9][0-9][0-9][0-9].*)"
		strNameOnly = re.Replace(strNameOnly, "$1 $2")
	loop while strNameOnly <> strNameOnlyOld

Thanks a lot. It works great.
The great thing with this Multi RegEx is that you can get a preview.

But before when I put both RegEx in a button I didn't get a preview.

Just to be sure. If I use the settings->backup restore and make a .ocb file, this will also include all the renaming scripts also?

Yes. I just upgraded from WiinXP to Win7, and after doing a restore (in DOpus), my custom file renaming templates reappeared. (Good thing, too, because in my hurry to upgrade, I forgot to manually save DOpus' configuration directory like I usually do, you know, just in case. :slight_smile:)

Wait. Hold that thought. I also used Windows Settings Transfer wizard thingy which restored my application data, so I can't save for sure. Never mind. Sorry.

Yes, rename presets are included in the backup.

I needed the same regex. Searched google and this came up! :smile:
Hopefully I will be able to get it to work.... again! Things has changed.