Use AI Generated Regex script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
CCarmichael
Posts: 21
Joined: 28 Apr 2022 13:07

Use AI Generated Regex script

Post by CCarmichael »

Hi,

I know there are multiple topics on the batch renaming of files using RegEx already, and this is probably very simple, however could someone please provide guidance on using the following to rename mp4 files currently titled "Video" to be "Video - (Folder name)" after " - ". Using the Bulk Rename Utility RegEx generator I was given the following where I am presuming "^$Video" to be keeping the current element of the file name:

Match: ^Video$
Replace: Video - <folder{after: - }{before: (+ Video)}>

For example: "Video" would become "Video - Debut" when located in a folder "[01-03] Subject - Debut (+Video)"

How do I go about entering this generated RegEx into the Rename Special: RegExp Rename tool or should I be using another tool?

Thank you very much.

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

Re: Use AI Generated Regex script

Post by highend »

And the rule for getting the "folder" name (which is actually only a part of it) is?

Code: Select all

[01-03] Subject - Debut (+Video)
Are ___ALL___ of your folders named that way?
If not, how are they named?
One of my scripts helped you out? Please donate via Paypal

CCarmichael
Posts: 21
Joined: 28 Apr 2022 13:07

Re: Use AI Generated Regex script

Post by CCarmichael »

highend wrote: ↑30 Oct 2026 19:42 And the rule for getting the "folder" name (which is actually only a part of it) is?

Code: Select all

[01-03] Subject - Debut (+Video)
Are ___ALL___ of your folders named that way?
If not, how are they named?
Good question.
There are 2 formats, which are similar.
They are (Dates are examples [Day-Month]):
1. [01-03] Subject - Set Title (+Video) or
2. [02-10] Subject - Set Title (Video only)

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

Re: Use AI Generated Regex script

Post by highend »

Code: Select all

    $items = <get SelectedItemsPathNamesSlashed>;
    $files = formatlist($items, "f", <crlf>, "!*\");

    setting "BackgroundFileOps", 0;
    foreach($file, $files, <crlf>, "e") {
        $parent = gettoken($file, -2, "\"); // [01-03] Subject - Set Title (+Video) | [02-10] Subject - Set Title (Video only)
        $parent = gettoken($parent, -1, " - ", "t");
        $parent = regexreplace($parent, "^(.+?)([ ]+\(\+?Video.*?\))", "$1");
        if ($parent) { renameitem(gpc($file, "base") . " - " . $parent, $file); }
    }
One of my scripts helped you out? Please donate via Paypal

CCarmichael
Posts: 21
Joined: 28 Apr 2022 13:07

Re: Use AI Generated Regex script

Post by CCarmichael »

highend wrote: ↑30 Oct 2026 20:53

Code: Select all

    $items = <get SelectedItemsPathNamesSlashed>;
    $files = formatlist($items, "f", <crlf>, "!*\");

    setting "BackgroundFileOps", 0;
    foreach($file, $files, <crlf>, "e") {
        $parent = gettoken($file, -2, "\"); // [01-03] Subject - Set Title (+Video) | [02-10] Subject - Set Title (Video only)
        $parent = gettoken($parent, -1, " - ", "t");
        $parent = regexreplace($parent, "^(.+?)([ ]+\(\+?Video.*?\))", "$1");
        if ($parent) { renameitem(gpc($file, "base") . " - " . $parent, $file); }
    }
Thanks @highend, would you be able to provide the steps to use this as for some reason I’m unable to understand how to use the tool.

Thanks again.

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

Re: Use AI Generated Regex script

Post by highend »

It's a script. put it on a button, a user defined command, whatever you like...
One of my scripts helped you out? Please donate via Paypal

CCarmichael
Posts: 21
Joined: 28 Apr 2022 13:07

Re: Use AI Generated Regex script

Post by CCarmichael »

highend wrote: ↑30 Oct 2026 21:57 It's a script. put it on a button, a user defined command, whatever you like...
Thanks very much, this works great :)

Post Reply