regexp rename pattern list

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Grey Wolf
Posts: 2
Joined: 13 May 2020 15:42

regexp rename pattern list

Post 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?

highend
Posts: 13357
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: regexp rename pattern list

Post by highend »

It uses the vb6 regex engine. Google should know everything about it
One of my scripts helped you out? Please donate via Paypal

Grey Wolf
Posts: 2
Joined: 13 May 2020 15:42

Re: regexp rename pattern list

Post 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.

highend
Posts: 13357
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: regexp rename pattern list

Post 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;
One of my scripts helped you out? Please donate via Paypal

matewo
Posts: 70
Joined: 03 Jun 2018 21:35

Re: regexp rename pattern list

Post 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

Post Reply