I've been at this for hours, and I just can't get this figured out.

I have a regex I'd like to use in a button script. I have the regex working in the RENAME GUI tool; I just can't figure out the syntax for the button script.

Here is my attempt:

rename REGEXP PATTERN="(.) (..).xxx" FROM ".xxx" TO "\"

Something much be wrong with the syntax ... ANY help would be VERY much appreciated.

This is almost certainly solvable.
I see several problems with your syntax though.
Could you post an example of a rename you wish to accomplish?

As a first step get rid of the From clause.
A second step is to look at your usage of the '' character .
This character escapes the normal RegExp usage of the character that immediately follows it.
In other words, if you want to specify the actual '' character, you need to preceed \ with .
The actual character '' is specified by \ .

I'm not at all certain yet what you are attempting here.

Can you also tell us what that code is ?

Let us know !
I do think this easily solvable.


Alright ...

I'm looking to remove something from a filename.

foo (fo).xxx

I want to rename to:

As you can see by the attached picture, I have successfully done this via the rename tool. (Note: I want ANY two chars between the parens to be removed).

Now, I just want to duplicate it in script.

Thank you!!

You almost have it.

How about

Rename REGEXP PATTERN="(.*)(\(..\))(\.xxx)" TO="\1\3"

Of course there are several solutions to this problem.
I thought this was a good place to start.
The quotes will help if there happen to be space characters in the filename.
I really haven't tested it though.


Looks like I missed a space character in there.

Rename REGEXP PATTERN="(.*)( \(..\))(\.xxx)" TO="\1\3"


It didn't initially work as I had hoped (that script only works on SELECTED files - which didn't work out for my needs) - but the syntax you provided got me through the hard times :slight_smile:

My final solution: (for anyone else that might be trying to accomplish the same thing)

Rename REGEXP PATTERN="(.) (..).xxx" TO="\" FROM=".xxx"

... This performed what I needed. I added the FROM= to allow it to work on unselected files.

Thanks a bunch guys ... you never fail me! :slight_smile:

I didn't know it.
I would have just selected all files and run my solution.

I'm glad you have it now though.
Isn't it just amazing what you can learn here?


It is ...

It's even MORE amazing that 99.9% of anything I want to do with files can be done one way or another with Dopus ...