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.
Use AI Generated Regex script
-
highend
- Posts: 15016
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Use AI Generated Regex script
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?
Code: Select all
[01-03] Subject - Debut (+Video)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
Good question.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?Code: Select all
[01-03] Subject - Debut (+Video)
If not, how are they named?
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
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
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.highend wrote: ↑30 Oct 2026 20:53Code: 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 again.
-
highend
- Posts: 15016
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Use AI Generated Regex script
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
XYplorer Beta Club