Need help with renaming/replacing filenames

Inspirated by Nudel's rename expressions maybe someone could solve this:

Often files are filled with "_" or "." instead of a space.

A simple replace would do the job, but how can I replace all "_" and "." in one step? Especially the "." of an extension shouldn't be removed.

This button replaces underscores with spaces:

<?xml version="1.0"?> <button display="both"> <label>Underscores to Spaces</label> <icon1>16</icon1> <function type="normal"> <instruction>rename PATTERN=&quot;_&quot; TO=&quot; &quot; FINDREP</instruction> <instruction>@NODESELECT</instruction> </function> </button>

You could do it with a Rename Preset as well. It's just a Find & Replace rename from "_" to " ".

For converting . to spaces, excluding the last . in the filename, you need something slightly more complex. The multi-regexp rename vbscript I posted yesterday could be used for this, but you can also do it with a single regexp rename without resorting to vbscript:

Regexp rename from

^(.).(...*)$#

to

\1 \2

The # at the end of the search string makes it "global", which means it will keep replacing matches until there are none left, instead of just doing the first match. The rest of the pattern finds a . that has at least one other . somewhere after it and replaces it with a space.

Oh, if you want to replace both . and _ with spaces at once then this will do it:

Regexp rename from

^(.)(.|_)(...*)$#

to

\1 \3