Page 1 of 1

regexp rename pattern list

Posted: 20 Apr 2024 23:43
by Grey Wolf
I absolutely LOVE this program but I'm having trouble finding documentation on what patterns do what in RegExp rename. I have found several posts on "try this" for specifics of other requests but nothing for "here are all the patterns and what each does". Am I just missing it? Is there a comprehensive listing somewhere?

Re: regexp rename pattern list

Posted: 20 Apr 2024 23:51
by highend
It uses the vb6 regex engine. Google should know everything about it

Re: regexp rename pattern list

Posted: 21 Apr 2024 00:44
by Grey Wolf
Thank you! I'll look for that. On the off chance that someone here is seeking a challenge, I'm trying to use RegExp rename to accomplish three things:

1) Rename a large number of files of the format Moviename - 2010.mkv to Moviename (2010).mkv (where 2010 could be anything from 1940 to 2024) without having to do each one separately and with keeping the original year in the new name. Lot of years between 1940 and 2024.
2) Rename a large number of files of similar format as 1, but rather 1940 - Moviename.mkv to Moviename (1940).mkv. Same as above, keeping the original year in the new name.
3) Rename a large number of files that have "." between words in the name (ex: The.Longest.Yard) and exchanging the "." for a space.

Any help would be greatly appreciated.

Re: regexp rename pattern list

Posted: 21 Apr 2024 06:05
by highend
Select all files to be renamed
Execute the script
Check if there are any dupes, if yes, exit the rename preview, resolve them, run the script again

Code: Select all

    $items = <get SelectedItemsPathNames>;
    end (!$items), "No item(s) selected, aborted!";

    $new = "";
    foreach($item, $items, <crlf>, "e") {
        if (exists($item) == 2) { continue; } // Do NOT process folders!
        $path = gpc($item, "path");
        $base = gpc($item, "base");
        $ext  = gpc($item, "ext");

        // 1940 - Moviename => Moviename (1940)
        $pattern = "^([1-2]\d{3})([ ]*-[ ]*)(.+?)$";
        $base    = regexreplace($base, $pattern, "$3 ($1)");

        // Moviename - 2010 => Moviename (2010)
        $pattern = "^(.+?)([ ]*-[ ]*)([1-2]\d{3})$";
        $base    = regexreplace($base, $pattern, "$1 ($3)");

        // Dots
        $base = replace($base, ".", " ");

        $new .= $path . "\" . $base . "." . $ext . <crlf>;
    }
    $new = trim($new, <crlf>, "R");

    rename "l", $new, "p", $items, 64;

Re: regexp rename pattern list

Posted: 22 Apr 2024 10:38
by matewo
Hi Grey Wolf,
highend wrote: 20 Apr 2024 23:51 It uses the vb6 regex engine. Google should know everything about it
You might (also) want to have a look into Best regards, Markus