I am new to XYplorer and this forum so please answer in newby talk! I have many filename similar to nikita.s02e11.HDTV.XviD-ASAP.[VTV].avi
and would like thrm to be renamed to: Nikita S02E11.avi
I have looked into regular expressions but I'm sorry too admit that that subject is over my head. Any help would be greatly appreciated.
Modify selected file names
-
j_c_hallgren
- XY Blog Master
- Posts: 5826
- Joined: 02 Jan 2006 19:34
- Location: So. Chatham MA/Clearwater FL
- Contact:
Re: Modify selected file names
Hi and welcome to the XY forums!
Just wanting to make sure of your "problem definition":
1) all involved files have 5 name segments (and thus 4 '.') before the extension, right?
2) you want to uppercase the 2nd segment in all cases?
3) and you want the first char of 1st segment also uppercased?
Just wanting to make sure of your "problem definition":
1) all involved files have 5 name segments (and thus 4 '.') before the extension, right?
2) you want to uppercase the 2nd segment in all cases?
3) and you want the first char of 1st segment also uppercased?
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
Re: Modify selected file names
Super fast reply, thanks. Yes to all three of your questions. Looking forward to your decription of how to acomplish this!!!
-
j_c_hallgren
- XY Blog Master
- Posts: 5826
- Joined: 02 Jan 2006 19:34
- Location: So. Chatham MA/Clearwater FL
- Contact:
Re: Modify selected file names
Unfortunately, while I'm often quick at replies, I'm not that great at regex's eithersouthwick wrote:Super fast reply, thanks. Yes to all three of your questions. Looking forward to your decription of how to acomplish this!!!
However, we have a GREAT set of regular users here so I'm sure you'll hear from one of them within a few hours at most with a solution.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
Rename using parts only and change case too
Hi and welcome. Thanks jc
RegEx: i am not sure if we can use \u \L syntax with XYplorer regex engine. Anyway...
So instead we can use an little script to do such things (if you use the pro version?) like this one;
Whit this script we can split the file name into parts and also change the case at easy.
For how to use such an script see my footer or read the help.
If the msgbox shows the right modifications we can enable the real renaming. Even we can loop through all (selected) files.
.
RegEx: i am not sure if we can use \u \L syntax with XYplorer regex engine. Anyway...
So instead we can use an little script to do such things (if you use the pro version?) like this one;
Code: Select all
$ITEM = "<curname>";
//$ITEM = "nikita.s02e11.HDTV.XviD-ASAP.[VTV].avi";
// Nikita S02E11.avi
//strpos(haystack, needle, [start], [matchcase])
$DotPos1 = strpos($ITEM, ".");
//substr(string, [start], [length])
$Part1 = substr($ITEM, , $DotPos1);
$Part1 = recase($Part1, "sentence");
//strpos(haystack, needle, [start], [matchcase])
$DotPos2 = strpos($ITEM, ".", $DotPos1);
//substr(string, [start], [length])
$Part2 = substr($ITEM, $DotPos1 +1, $DotPos2);
$Part2 = recase($Part2, "upper");
$DotLast = strpos($ITEM, ".", -1);
$Ext = substr($ITEM, $DotLast);
msg $Part1 $Part2$Ext;
// renameitem($Part1 $Part2$Ext, $ITEM);
For how to use such an script see my footer or read the help.
If the msgbox shows the right modifications we can enable the real renaming. Even we can loop through all (selected) files.
.
Re: Modify selected file names
This was my solution (although I'm a bit late):
Tested it with some of your filenames and it's working fine so far.
You just have to select all files that you want to be renamed and execute this script afterwards.
Code: Select all
$SelectedItems = get("SelectedItemsPathNames", "|");
foreach($Item, "$SelectedItems", "|") {
$FindBS = strpos($Item, "\", -1);
$DstPath = substr($Item, 0, $FindBS);
$FindExt = strpos($Item, ".", -1);
$Ext = substr($Item, $FindExt +1, );
$Filename = substr($Item, $FindBS +1, ($FindExt - $FindBS -1));
$First = recase(gettoken($Filename, 1, "."), t);
$Second = recase(gettoken($Filename, 2, "."), u);
rename b, "$First $Second.$Ext /e", p, "$Item";
}You just have to select all files that you want to be renamed and execute this script afterwards.
One of my scripts helped you out? Please donate via Paypal
Re: Modify selected file names
My 0.02$...
The first idea that comes to my mind is that you've a folder with files named nikita.s02e##.HDTV.XviD-ASAP.[VTV].avi , where ## stands for a two-digit number.
Easiest thing to do is select all the episodes of the season, then press Shift+F2. In the rename box that will appear write Nikita S02E<#01>, then press Enter. You should accomplish what you want (at least, experience tells me so
).
The first idea that comes to my mind is that you've a folder with files named nikita.s02e##.HDTV.XviD-ASAP.[VTV].avi , where ## stands for a two-digit number.
Easiest thing to do is select all the episodes of the season, then press Shift+F2. In the rename box that will appear write Nikita S02E<#01>, then press Enter. You should accomplish what you want (at least, experience tells me so
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Don sees all [cit. from viewtopic.php?p=124094#p124094]
Re: Modify selected file names
Thank you all!! I will try to learn from each code(?) that you so kindly submitted.
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: Modify selected file names
I'd change Stefans last 2 lines to:
(Especially the quotes around "$Part1 $Part2$Ext" - the rest is cosmetic...)
And I must say: I like highends "gettoken"s - very direct!
Code: Select all
msg "$ITEM<crlf>$Part1 $Part2$Ext";
// renameitem("$Part1 $Part2$Ext", "$ITEM");
And I must say: I like highends "gettoken"s - very direct!
Re: Modify selected file names
I'm not sure if it would help but if someone could use it as a base-line and modify it. It's was post
http://www.xyplorer.com/xyfc/viewtopic. ... +Extension+ Regular Expression Renaming Suite
The secret I took from this was (\.[^\.]*) this obtains the extension regardless of how many dot's that are in the name. I've been experimenting for the same reason to modify TV file names that I download, so I can rename them automatically.

http://www.xyplorer.com/xyfc/viewtopic. ... +Extension+ Regular Expression Renaming Suite
The secret I took from this was (\.[^\.]*) this obtains the extension regardless of how many dot's that are in the name. I've been experimenting for the same reason to modify TV file names that I download, so I can rename them automatically.

Re: Modify selected file names
The question is, if your regex would be faster than our two lines
And the next question is, does that matter when you're about to rename a single / a handful of files...

Code: Select all
$FindExt = strpos($Item, ".", -1);
$Ext = substr($Item, $FindExt +1, );One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club