Need script to set extension to lower case

Discuss and share scripts and script files...
Post Reply
admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Need script to set extension to lower case

Post by admin »

Is that possible with RegExp, or do I have to add a new script command tolowercase or lcase?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Need script to set extension to lower case

Post by jacky »

admin wrote:Is that possible with RegExp, or do I have to add a new script command tolowercase or lcase?
Can't be done with regexp no, it doesn't change case.

Now that the bug found today about Batch Rename and same case has been fixed, I think this little script should work, but obviously it only works with one item selected. (That's of course until we get a way to loop though them all ;))

Code: Select all

set $base, <curbase>;
 // lowercase
 #127;
 set $ext, <curext>;
 rename , "$base.$ext/e";
BTW tolowercase or lcase are very bad names if it only affects the extension, as they could easily be confused for #127; (File / Rename Special / aaa aa.aaa) I'd recommend to add it there, or add a parameter : f|b|e for full filename, base only, extension only (unless of course that was your plan all along, which may very well be the case. Probably so. So yeah just add your lowercase & uppercase commands already then ;))
Proud XYplorer Fanatic

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Need script to set extension to lower case

Post by TheQwerty »

jacky wrote:
admin wrote:Is that possible with RegExp, or do I have to add a new script command tolowercase or lcase?
Can't be done with regexp no, it doesn't change case.
Quite a few implementations do support the use of \u \U \l and \L in the replacement pattern to change case.

That said, the one used by XY doesn't seem to be one of them.

admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Need script to set extension to lower case

Post by admin »

jacky wrote:
admin wrote:Is that possible with RegExp, or do I have to add a new script command tolowercase or lcase?
Can't be done with regexp no, it doesn't change case.

Now that the bug found today about Batch Rename and same case has been fixed, I think this little script should work, but obviously it only works with one item selected. (That's of course until we get a way to loop though them all ;))

Code: Select all

set $base, <curbase>;
 // lowercase
 #127;
 set $ext, <curext>;
 rename , "$base.$ext/e";
BTW tolowercase or lcase are very bad names if it only affects the extension, as they could easily be confused for #127; (File / Rename Special / aaa aa.aaa) I'd recommend to add it there, or add a parameter : f|b|e for full filename, base only, extension only (unless of course that was your plan all along, which may very well be the case. Probably so. So yeah just add your lowercase & uppercase commands already then ;))
Script works! Merci! :D

Of course, tolowercase or lcase were meant as general string functions!

admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Need script to set extension to lower case

Post by admin »

jacky wrote:

Code: Select all

set $base, <curbase>;
 // lowercase
 #127;
 set $ext, <curext>;
 rename , "$base.$ext/e";
This seems to do the same job, but shorter:

Code: Select all

set $base, <curbase>; 
 // lowercase 
 #127; 
 rename , $base;

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Oh yeah, nice, yes it does, silly me!
Proud XYplorer Fanatic

Post Reply