Page 1 of 1
Use AI Generated Regex script
Posted: 30 Oct 2026 19:13
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.
Re: Use AI Generated Regex script
Posted: 30 Oct 2026 19:42
by highend
And the rule for getting the "folder" name (which is actually only a part of it) is?
Are ___ALL___ of your folders named that way?
If not, how are they named?
Re: Use AI Generated Regex script
Posted: 30 Oct 2026 20:04
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?
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)
Re: Use AI Generated Regex script
Posted: 30 Oct 2026 20:53
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); }
}
Re: Use AI Generated Regex script
Posted: 30 Oct 2026 21:29
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.
Re: Use AI Generated Regex script
Posted: 30 Oct 2026 21:57
by highend
It's a script. put it on a button, a user defined command, whatever you like...
Re: Use AI Generated Regex script
Posted: 31 Oct 2026 11:20
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
