Help on renaming files
-
unoentremil
- Posts: 21
- Joined: 26 Dec 2014 19:20
Help on renaming files
Hi,
Would someone help on how should I rename a group of selected files following this pattern:
movie name in spanish - original movie name, year.[blablabla].extension
movie name in spanish - original movie name, year.blablabla.extension
into this one?:
movie name in spanish (year).(original movie name).[blablabla].extension
or
movie name in spanish (year)\movie name in spanish (year).(original movie name).[blablabla].extension (same as above but also creating a folder)
I think the most difficult part is how to keep the information contained after the original movie name, usually in brackets, but not always while always after as a dot (used as separator).
This new format is required by Media Centers, scrappers and the like (ideally each movie into it's own folder) and I'm going crazy doing it manually over hundreds of files.
TIA,
Diego
Would someone help on how should I rename a group of selected files following this pattern:
movie name in spanish - original movie name, year.[blablabla].extension
movie name in spanish - original movie name, year.blablabla.extension
into this one?:
movie name in spanish (year).(original movie name).[blablabla].extension
or
movie name in spanish (year)\movie name in spanish (year).(original movie name).[blablabla].extension (same as above but also creating a folder)
I think the most difficult part is how to keep the information contained after the original movie name, usually in brackets, but not always while always after as a dot (used as separator).
This new format is required by Media Centers, scrappers and the like (ideally each movie into it's own folder) and I'm going crazy doing it manually over hundreds of files.
TIA,
Diego
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Help on renaming files
select all those files, then do a regexp rename with this pattern:
(File > Rename Special > Regexp Rename.)
heh, I had some time so here's an explanation:
Code: Select all
^(.*?)\s-\s(.*?),\s(\d{4})\.\[?(.*?)\]?\.([^\.]+)$ > $1 ($3).$2.[$4].$5heh, I had some time so here's an explanation:
Code: Select all
^(.*?)\s-\s(.*?),\s(\d{4})\.\[?(.*?)\]?\.([^\.]+)$ > $1 ($3).$2.[$4].$5
| \_/ \___/ \_/ \_/ \___/ | | \_/ | | \___/ | | | | | |
start | | | | | dot| | | | | end| (1)(3) (2) (4)
| " - " | | 4nums(3) | blah | dot | |
spanish name(1) | ", " | | extension(4)|
original name(2) optional sq brackets |
| replacement
string groupsIcon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Help on renaming files
to create --and move into-- folders, your need a dose of ::scripting;
Again select all those files and run this script. (Menu > Scripting > Run Script >> paste this code)
You should test these with a few files before regular use.
Again select all those files and run this script. (Menu > Scripting > Run Script >> paste this code)
Code: Select all
$matcher = '^(.*?)\s-\s(.*?),\s(\d{4})\.\[?(.*?)\]?\.([^\.]+)$';
// step;
foreach($itm, get('selectedItemsPathNames','|')){
$path = getpathcomponent($itm, 'path');
$name = getpathcomponent($itm, 'file');
if !(regexmatches($nameStr, $matcher)){ continue; }
$nameDir = regexreplace($name, $matcher, '$1 ($3)');
$nameItm = regexreplace($name, $matcher, '$1 ($3).$2.[$4].$5');
moveas $nameItm, "$path\$nameDir", $itm;
}Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
unoentremil
- Posts: 21
- Joined: 26 Dec 2014 19:20
Re: Help on renaming files
Thanks a lot Sammay,
This is Great! We're almost there
. This is the result I get:
Original:
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.[DVD.ES.EN.Divx5.AC3].avi
Output (using your Regexp):
La alegre divorciada (1934).The Gay Divorcee. Mark Sandrich.[DVD.ES.EN.Divx5.AC3].avi
As you see, the original name and the director are not contained into brackets while $2 seems to contain both fields. Would you please refine it to separate director and original name?
Apart from that:
1) I've just got a recommendation from FileBot developer to put the original movie name at the beginning (to make it fully compatible with all the scrappers and software). Obviously, separating the fields we would just had to swap the order on the replacement part/output (easy, even for me):
The Gay Divorcee (1934).(La alegre divorciada).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].avi
2) Many of the files contain actors information after the director. I have decided that it's better not keeping that information (Too long file names, you know):
Examples:
(input)
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934. F. Astaire,G. Rogers,E. E. Horton.[DVD.ES.EN.Divx5.AC3].avi
Sombrero de copa - Top Hat. Mark Sandrich, 1935. F. Astaire,G. Rogers.[DVD.EN.ES.Xvid.AC3.MP3].avi
Una mujer se rebela - A Woman Rebels. Mark Sandrich, 1936. K. Hepburn,H. Marshall.[DVD.VO-EN.Xvid.MP3].avi
Output:
The Gay Divorcee (1934).(La alegre divorciada).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].avi
____
Regarding the script, I think I still prefer using the Spanish name for folders because my family don't understand a word of English
Not a problem, I hope, since the scrappers I know offer the option to use the file name or the folder name. Two choices, better than one.
Output:
Mark Sandrich\La alegre divorciada (1934)\The Gay Divorcee (1934).(La alegre divorciada).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].avi
Thanks again!
This is Great! We're almost there
Original:
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.[DVD.ES.EN.Divx5.AC3].avi
Output (using your Regexp):
La alegre divorciada (1934).The Gay Divorcee. Mark Sandrich.[DVD.ES.EN.Divx5.AC3].avi
As you see, the original name and the director are not contained into brackets while $2 seems to contain both fields. Would you please refine it to separate director and original name?
Apart from that:
1) I've just got a recommendation from FileBot developer to put the original movie name at the beginning (to make it fully compatible with all the scrappers and software). Obviously, separating the fields we would just had to swap the order on the replacement part/output (easy, even for me):
The Gay Divorcee (1934).(La alegre divorciada).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].avi
2) Many of the files contain actors information after the director. I have decided that it's better not keeping that information (Too long file names, you know):
Examples:
(input)
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934. F. Astaire,G. Rogers,E. E. Horton.[DVD.ES.EN.Divx5.AC3].avi
Sombrero de copa - Top Hat. Mark Sandrich, 1935. F. Astaire,G. Rogers.[DVD.EN.ES.Xvid.AC3.MP3].avi
Una mujer se rebela - A Woman Rebels. Mark Sandrich, 1936. K. Hepburn,H. Marshall.[DVD.VO-EN.Xvid.MP3].avi
Output:
The Gay Divorcee (1934).(La alegre divorciada).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].avi
____
Regarding the script, I think I still prefer using the Spanish name for folders because my family don't understand a word of English
Output:
Mark Sandrich\La alegre divorciada (1934)\The Gay Divorcee (1934).(La alegre divorciada).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].avi
Thanks again!
Last edited by unoentremil on 29 Jul 2015 16:25, edited 2 times in total.
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help on renaming files
Changed pattern...
Code: Select all
$pattern = "^(.*?)\s-\s(.*?)\.\s(.*?),\s(\d{4})\.([^\[]*)(\[.*?)$";
foreach($item, get("selectedItemsPathNames", "|")) {
$path = getpathcomponent($item, "path");
$name = getpathcomponent($item, "file");
if !(regexmatches($item, $pattern)) { continue; }
$nameDir = regexreplace($name, $pattern, "$1 ($4)");
$nameItem = regexreplace($name, $pattern, "$1 ($4).($2).($3).$6");
moveas $nameItem, "$path\$nameDir", $item;
}One of my scripts helped you out? Please donate via Paypal
-
unoentremil
- Posts: 21
- Joined: 26 Dec 2014 19:20
Re: Help on renaming files
Thanks Highend,
Excuse my ignorance but could you please provide the complete modified RegEx expression to apply over a group of previously selected files?
Thanks!
Excuse my ignorance but could you please provide the complete modified RegEx expression to apply over a group of previously selected files?
Thanks!
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help on renaming files
One of my scripts helped you out? Please donate via Paypal
-
unoentremil
- Posts: 21
- Joined: 26 Dec 2014 19:20
Re: Help on renaming files
Works like a charm. Now that the fields are separated, I can swap the order easily:highend wrote:![]()
Code: Select all
^(.*?)\s-\s(.*?)\.\s(.*?),\s(\d{4})\.([^\[]*)(\[.*?)$ > $1 ($4).($2).($3).$6
Code: Select all
^(.*?)\s-\s(.*?)\.\s(.*?),\s(\d{4})\.([^\[]*)(\[.*?)$ > $2 ($4).($1).($3).$61) Can we make the part in brackets optional? I mean: Hundreds of the files share this pattern but, unfortunately, not all. Some do not contain the media info at all OR is not contained in [Brackets] so are skipped.
Examples of skipped files would be:
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.DVD.ES.EN.Divx5.AC3.avi
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.avi
La alegre divorciada, (The Gay Divorcee), Mark Sandrich, 1934.avi
La alegre divorciada, The Gay Divorcee, (Mark Sandrich, 1934).avi
*EDITED HERE FOR CLARIFICATION, TO SEPARATE POINT 2 FROM POINT 3 (SEPARATED REQUIREMENT)* (Sorry Highend, I edited it while you were working on the refinement of the script to cover more groups)
2) Now the situation gets even worst: Files ONLY with Spanish or English title
La alegre divorciada. Mark Sandrich, 1934.blabla.extension
to:
La alegre divorciada (1934).(Mark Sandrich).blabla.extension
(I would complete it later to include the English title using a scraper)
Any idea??? Using a different RegEx, maybe?
Obviously, not all matches can be included but the more we cover, the more hours I'll save so I really, really, really appreciate your help guys (Count with a donation, Highend). I really need to finally complete ordering this collection to concentrate on more productive tasks
*EDITED HERE TO ADD POINT 3 - THE FINAL AND DEFINITIVE STEP*
3) Last but not least, How to Swap Original and Spanish and English titles on all of the already renamed (optimized) files to follow the software developer's recommendation. Obviously another much simpler expression.
Since it's impossible for a script to understand languages, this step should be applied ONLY to finish the job, separately, when all the files have been modified and share the same format because currently I have a mix of hundreds of files renamed manually and all the remaining ones.
This final step consist in changing this:
Spanish title (YEAR).(English title).(Director).[Blabla].extension
Into this:
English title (YEAR).(Spanish title).(Director).[Blabla].extension
Best,
Diego
Last edited by unoentremil on 30 Jul 2015 02:13, edited 1 time in total.
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help on renaming files
1. Don't know if this one catches everything, no time to try them all out...
Edit: Small changes. A few non-capturing groups to match more possible scenarios...
2.
Edit: Small changes. A few non-capturing groups to match more possible scenarios...
Code: Select all
$pattern1 = "^(.*?)(?:\s-\s|,\s|\.\s)(.*?)(?:\.|,)\s(.*?)(?:\.|,)\s(\d{4})(.*?)(\[DVD.*?])\.(.*)$"; // Files with [...] before the extension
$pattern2 = "^(.*?)(?:\s-\s|,\s|\.\s)(.*?)(?:\.|,)\s(.*?)(?:\.|,)\s(\d{4})(.*?)(DVD.*)\.(.*)$"; // Files with missing [] but DVD... before the extension
$pattern3 = "^(.*?)(?:\s-\s|,\s|\.\s)(.*?)(?:\.\s|,\s)(.*?),\s(\d{4})(.*)\.(.*)$"; // Files with missing [...] before the extension
$pattern4 = "^(.*?)(?:\.\s|,\s)(.*?),\s(\d{4})(.*)\.(.*)$"; // Files with missing english title...
foreach($item, get("selectedItemsPathNames", "|")) {
$path = getpathcomponent($item, "path");
$fileName = regexreplace(getpathcomponent($item, "file"), "(\(|\))"); // Remove parentheses
if (regexmatches($fileName, $pattern1)) {
$nameDir = regexreplace($fileName, $pattern1, "$1 ($4)");
$nameItem = regexreplace($fileName, $pattern1, "$1 ($4).($2).($3).$6.$7");
} elseif (regexmatches($fileName, $pattern2)) {
$nameDir = regexreplace($fileName, $pattern2, "$1 ($4)");
$nameItem = regexreplace($fileName, $pattern2, "$1 ($4).($2).($3).[$6].$7");
} elseif (regexmatches($fileName, $pattern3)) {
$nameDir = regexreplace($fileName, $pattern3, "$1 ($4)");
$nameItem = regexreplace($fileName, $pattern3, "$1 ($4).($2).($3).$6");
} elseif !(regexmatches($fileName, "-")) { // No english title because of missing "-"?
$nameDir = regexreplace($fileName, $pattern4, "$1 ($3)");
$nameItem = regexreplace($fileName, $pattern4, "$1 ($3).($2).$5");
}
moveas $nameItem, "$path\$nameDir", $item;
}Code: Select all
^(.*?)\s(\(.*?\))\.\((.*?)\)\.(\(.*?\)).(.*)$ > $3 $2.($1).$4.$5One of my scripts helped you out? Please donate via Paypal
-
unoentremil
- Posts: 21
- Joined: 26 Dec 2014 19:20
Re: Help on renaming files
Highend,
No worries, you have to sleep man
Excellent Job! I'm impressed, really.
Firstly I have tested the RegEx to swap English and Spanish titles on previously formatted files (note that point 2 is now point 3 because I edited a bit the original questions). Well, It works perfectly leaving intact the final technical part contained in brackets.
Secondly, I have created a bunch of files with most common variations to test the script:
La alegre divorciada - The Gay Divorcee, 1934.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934. F. Astaire,G. Rogers,E. E. Horton.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).(Mark Sandrich).DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).(The Gay Divorcee).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada, (The Gay Divorcee), Mark Sandrich, 1934.txt
La alegre divorciada, The Gay Divorcee, (Mark Sandrich, 1934).txt
La alegre divorciada. Mark Sandrich, 1934. F. Astaire,G. Rogers,E. E. Horton.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada. Mark Sandrich, 1934.DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada.Mark Sandrich.1934.DVD.ES.EN.Divx5.AC3.txt
Many files have been renamed and moved perfectly, but not all (as you expected). Several different folders are created and the names not always match the desired output format. I have also added a few more variations to cover the most common scenarios
I could have copied and pasted the results here for you to see, but I think that it would only generate confusion. If you don't mind, I think it's better for you to try them for yourself from the list above.
Ufff, Almost forgot: Just in case, not all the files are marked with the DVD 'tag'. There are also:
BD
WEB-DL
HD
SAT
TV
VHS
If you could refine the script to cover these variations we could consider the work accomplished. The rest of the files that I have still pending to organize don't follow any clear pattern so I guess that it would be practically impossible to automate the job over them.
Best,
Diego
No worries, you have to sleep man
Excellent Job! I'm impressed, really.
Firstly I have tested the RegEx to swap English and Spanish titles on previously formatted files (note that point 2 is now point 3 because I edited a bit the original questions). Well, It works perfectly leaving intact the final technical part contained in brackets.
Secondly, I have created a bunch of files with most common variations to test the script:
La alegre divorciada - The Gay Divorcee, 1934.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934. F. Astaire,G. Rogers,E. E. Horton.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee. Mark Sandrich, 1934.DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).(Mark Sandrich).DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).(The Gay Divorcee).(Mark Sandrich).[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada, (The Gay Divorcee), Mark Sandrich, 1934.txt
La alegre divorciada, The Gay Divorcee, (Mark Sandrich, 1934).txt
La alegre divorciada. Mark Sandrich, 1934. F. Astaire,G. Rogers,E. E. Horton.[DVD.ES.EN.Divx5.AC3].txt
La alegre divorciada. Mark Sandrich, 1934.DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada.Mark Sandrich.1934.DVD.ES.EN.Divx5.AC3.txt
Many files have been renamed and moved perfectly, but not all (as you expected). Several different folders are created and the names not always match the desired output format. I have also added a few more variations to cover the most common scenarios
I could have copied and pasted the results here for you to see, but I think that it would only generate confusion. If you don't mind, I think it's better for you to try them for yourself from the list above.
Ufff, Almost forgot: Just in case, not all the files are marked with the DVD 'tag'. There are also:
BD
WEB-DL
HD
SAT
TV
VHS
If you could refine the script to cover these variations we could consider the work accomplished. The rest of the files that I have still pending to organize don't follow any clear pattern so I guess that it would be practically impossible to automate the job over them.
Best,
Diego
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help on renaming files
Code: Select all
foreach($item, get("selectedItemsPathNames", "|")) {
$nameDir = "";
$path = getpathcomponent($item, "path");
$fileName = regexreplace(getpathcomponent($item, "file"), "(\(|\))"); // Remove parentheses
// All components + format in []
$p1 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)(\[(DVD|WEB-DL|HD|SAT|TV|VHS).*?])\.(.*)$";
// All components + format (but not in [])
$p2 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)((DVD|WEB-DL|HD|SAT|TV|VHS).*)\.(.*)$";
// Missing format
$p3 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)\.(.*)$";
// Missing director, otherwise same as $p1
$p1_1 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)(\[(DVD|WEB-DL|HD|SAT|TV|VHS).*?])\.(.*)$";
// Missing director, otherwise same as $p2
$p2_1 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)((DVD|WEB-DL|HD|SAT|TV|VHS).*)\.(.*)$";
if (regexmatches($fileName, $p1)) {
$nameDir = regexreplace($fileName, $p1, "$1 ($4)");
$nameItem = regexreplace($fileName, $p1, "$1 ($4).($2).($3).$6.$8");
} elseif (regexmatches($fileName, $p2)) {
$nameDir = regexreplace($fileName, $p2, "$1 ($4)");
$nameItem = regexreplace($fileName, $p2, "$1 ($4).($2).($3).[$6].$8");
} elseif (regexmatches($fileName, $p3)) {
$nameDir = regexreplace($fileName, $p3, "$1 ($4)");
$nameItem = regexreplace($fileName, $p3, "$1 ($4).($2).($3).$6");
} elseif (regexmatches($fileName, $p1_1)) {
$nameDir = regexreplace($fileName, $p1_1, "$1 ($3)");
$nameItem = regexreplace($fileName, $p1_1, "$1 ($3).($2).$5.$7");
} elseif (regexmatches($fileName, $p2_1)) {
$nameDir = regexreplace($fileName, $p2_1, "$1 ($3)");
$nameItem = regexreplace($fileName, $p2_1, "$1 ($3).($2).[$5].$7");
}
if ($nameDir) { moveas $nameItem, "$path\$nameDir", $item; }
}One of my scripts helped you out? Please donate via Paypal
-
unoentremil
- Posts: 21
- Joined: 26 Dec 2014 19:20
Re: Help on renaming files
Hello Highend,
The script works great on all the provided examples but it does 'nothing' on files separated by dots and other cases that contain the suggested sources (VHS, BD, etc):
Examples:
This one works:
La alegre divorciada - The Gay Divorcee, 1934.[DVD.ES.EN.Divx5.AC3].txt
But these, doesn't:
La alegre divorciada - The Gay Divorcee, 1934.[BD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee, 1934.[HD.ES.EN.Divx5.AC3].txt
Dot separated (none work)
La alegre divorciada (1934).The Gay Divorcee.Mark Sandrich.HD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).The Gay Divorcee.Mark Sandrich.VHS.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934. The Gay Divorcee. Mark Sandrich.WEB.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.[BD.ES.EN.Divx5.AC3].txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.BD.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.DVD.ES.EN.Divx5.AC3 - Copy.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.SAT.ES.EN.Divx5.AC3.txt
La alegre divorciada.1934.The Gay Divorcee.Mark Sandrich.SAT.ES.EN.Divx5.AC3.txt
La alegre divorciada. 1934.The Gay Divorcee.Mark Sandrich.SAT.ES.EN.Divx5.AC3.txt
Would it be possible to fix that? I wish I could understand how the script works but it's like Chinese to me.
Thanks a lot.
The script works great on all the provided examples but it does 'nothing' on files separated by dots and other cases that contain the suggested sources (VHS, BD, etc):
Examples:
This one works:
La alegre divorciada - The Gay Divorcee, 1934.[DVD.ES.EN.Divx5.AC3].txt
But these, doesn't:
La alegre divorciada - The Gay Divorcee, 1934.[BD.ES.EN.Divx5.AC3].txt
La alegre divorciada - The Gay Divorcee, 1934.[HD.ES.EN.Divx5.AC3].txt
Dot separated (none work)
La alegre divorciada (1934).The Gay Divorcee.Mark Sandrich.HD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).The Gay Divorcee.Mark Sandrich.VHS.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934. The Gay Divorcee. Mark Sandrich.WEB.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.[BD.ES.EN.Divx5.AC3].txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.BD.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.DVD.ES.EN.Divx5.AC3.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.DVD.ES.EN.Divx5.AC3 - Copy.txt
La alegre divorciada, 1934.The Gay Divorcee.Mark Sandrich.SAT.ES.EN.Divx5.AC3.txt
La alegre divorciada.1934.The Gay Divorcee.Mark Sandrich.SAT.ES.EN.Divx5.AC3.txt
La alegre divorciada. 1934.The Gay Divorcee.Mark Sandrich.SAT.ES.EN.Divx5.AC3.txt
Would it be possible to fix that? I wish I could understand how the script works but it's like Chinese to me.
Thanks a lot.
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Help on renaming files
Excuse me, I'm just gonna pop in here to say: How can something be fixed if you've never mentioned it before? Why do you keep replying with NEWER name structures? Especially RIGHT AFTER the earlier requests have been granted?unoentremil wrote:The script works great on all the provided examples but it does 'nothing' on files separated by dots and other cases that contain the suggested sources (VHS, BD, etc): [...]
Would it be possible to fix that? I wish I could understand how the script works but it's like Chinese to me.
You'd never mentioned earlier of these names where everything is dot-separated.
Pop out. Excuse me.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
highend
- Posts: 14953
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help on renaming files
Won't be catched...:
Rest should work:La alegre divorciada (1934).The Gay Divorcee.Mark Sandrich.HD.ES.EN.Divx5.AC3.txt
La alegre divorciada (1934).The Gay Divorcee.Mark Sandrich.VHS.ES.EN.Divx5.AC3.txt
Code: Select all
foreach($item, get("selectedItemsPathNames", "|")) {
$nameDir = "";
$path = getpathcomponent($item, "path");
$fileName = regexreplace(getpathcomponent($item, "file"), "(\(|\))"); // Remove parentheses
// All components + format in []
$p1 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)(\[(DVD|BD|WEB-DL|WEB|HD|SAT|TV|VHS).*?])\.(.*)$";
// All components + format (but not in [])
$p2 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)((DVD|BD|WEB-DL|WEB|HD|SAT|TV|VHS).*)\.(.*)$";
// Missing format
$p3 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)\.(.*)$";
// Year earlier, format in []
$p4 = "^([^,.-]+?)\s?(?:-|,|\.)\s?(\d{4})\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(.*?)(\[(DVD|BD|WEB-DL|WEB|HD|SAT|TV|VHS).*?])\.(.*)$";
// Year earlier, format (but not in [])
$p5 = "^([^,.-]+?)\s?(?:-|,|\.)\s?(\d{4})\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(.*?)((DVD|BD|WEB-DL|WEB|HD|SAT|TV|VHS).*)\.(.*)$";
// Missing director, otherwise same as $p1
$p1_1 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)(\[(DVD|BD|WEB-DL|WEB|HD|SAT|TV|VHS).*?])\.(.*)$";
// Missing director, otherwise same as $p2
$p2_1 = "^([^,.-]+?)\s?(?:-|,|\.)\s?([^,.-]+?)\s?(?:,|\.)\s?(\d{4})(.*?)((DVD|BD|WEB-DL|WEB|HD|SAT|TV|VHS).*)\.(.*)$";
if (regexmatches($fileName, $p1)) {
$nameDir = regexreplace($fileName, $p1, "$1 ($4)");
$nameItem = regexreplace($fileName, $p1, "$1 ($4).($2).($3).$6.$8");
} elseif (regexmatches($fileName, $p2)) {
$nameDir = regexreplace($fileName, $p2, "$1 ($4)");
$nameItem = regexreplace($fileName, $p2, "$1 ($4).($2).($3).[$6].$8");
} elseif (regexmatches($fileName, $p3)) {
$nameDir = regexreplace($fileName, $p3, "$1 ($4)");
$nameItem = regexreplace($fileName, $p3, "$1 ($4).($2).($3).$6");
} elseif (regexmatches($fileName, $p1_1)) {
$nameDir = regexreplace($fileName, $p1_1, "$1 ($3)");
$nameItem = regexreplace($fileName, $p1_1, "$1 ($3).($2).$5.$7");
} elseif (regexmatches($fileName, $p2_1)) {
$nameDir = regexreplace($fileName, $p2_1, "$1 ($3)");
$nameItem = regexreplace($fileName, $p2_1, "$1 ($3).($2).[$5].$7");
} elseif (regexmatches($fileName, $p4)) {
$nameDir = regexreplace($fileName, $p4, "$1 ($2)");
$nameItem = regexreplace($fileName, $p4, "$1 ($2).($3).($4).$6.$8");
} elseif (regexmatches($fileName, $p5)) {
$nameDir = regexreplace($fileName, $p5, "$1 ($2)");
$nameItem = regexreplace($fileName, $p5, "$1 ($2).($3).($4).[$6].$8");
}
if ($nameDir) { moveas $nameItem, "$path\$nameDir", $item; }
}One of my scripts helped you out? Please donate via Paypal
-
Stef123
Re: Help on renaming files
Different perspectives, imo. The pros like Sammay and highend approach it from the technical side, resulting in syntax that is almost impossible to grasp, let alone modify, by users not literate in RegEX.SammaySarkar wrote: Why do you keep replying with NEWER name structures? Especially RIGHT AFTER the earlier requests have been granted?
You'd never mentioned earlier of these names where everything is dot-separated.
For unoentremil the objective may have been a bit different, not so much to get a solution for one specific example down to the last dot, but rather how to break it up in delimited parts, how to get started on "positional" renaming or swapping. I completely gave up on doing this in XY, simply because it turned out too time-consuming.
I bet it's a lot of fun once you've got the expertise, like all advanced skills that are highly rewarding, but it takes time to tinker with it. For fast results I revert back to other tools that offer (relatively) easy input dialogs or other means for that end.
XYplorer Beta Club