Hello
It seems to me that expressions doesn't work in PATTERN parameter for Rename FINDREP.
This does nothing:
Rename PATTERN="[-_.]" TO=" " FINDREP
Hello
It seems to me that expressions doesn't work in PATTERN parameter for Rename FINDREP.
This does nothing:
Rename PATTERN="[-_.]" TO=" " FINDREP
They're not meant to. Find & Replace does a straight text search/replace - if you want to use regular expressions, use regular expressions mode.
But, correct me if I am wrong, in regexp mode there is no way to make multiple replacements in this way (equivalent to s/._-/ /g in perl)?
You can make a regex replacement repeat by adding # to the end of the pattern (or repeat a specific number of times, e.g. #3 to repeat three times). Anything more complex and you'll need to use VBScript.
@Xyzzy
I don't understand all of the Perl syntax, I'm more familiar with PHP.
Does this DOpus code help ?
@nodeselect
Rename REGEXP PATTERN="(.*)([-_\.])(.*\..*)#" TO="\1 \3" type=files
Rename REGEXP PATTERN="(.*)([-_\.])(.*)#" TO="\1 \3" type=dirs
To eliminate multiple space characters, modify the above code to this.
@nodeselect
Rename REGEXP PATTERN="(.*)([-_\.]| )(.*\..*)#" TO="\1 \3" type=files
Rename REGEXP PATTERN="(.*)([-_\.]| )(.*)#" TO="\1 \3" type=dirs
These codes may not be the best answer, but I think they may do what you are thinking.
To my surprise it works, but that also means that in DO regexps work like perl swap, not like match. This has an advantage in my situation, but is a problem when you want the standard behaviour.
Let's take filename 12341.txt
This
Rename REGEXP FROM="*.txt" PATTERN="(.*)1(.*)#" TO="\1\2"
removes all 1s, while it should remove just THE LAST! ![]()
So, how to remove just the last one, assuming that there are unknown numbers of 1s before it?
Oh, I think I am starting to understand. The '#' triggers multiple matching behaviour, effectively changing 'match' into 'swap'.
This is what actually jon stated and manual writes, but I've interpreted it as regex's {} operator (repetitions).
In a knee-jerk reaction I've interpreted DO regexs like the perl ones. While there is no difference in simple uses, there are in more advanced ones.
This should remove the last 1:
Rename REGEXP FROM="*.txt" PATTERN="(.*)1([^1]*)" TO="\1\2"
(Untested.)