HI,
I love using XYplorer to rename files, but I want to create a script that can do multiple things at the same time, as always seem to have to make several passes on file names to get them right for my use.
I want to convert them to lower case
then replace space and underscores with hyphens
then replace a range of odd characters with hyphens
Can anyone help me write a script, then assign it to the right hand mouse menu or a menu item or a keyboard shortcut ??
Script to do multiple pass rename
-
clarkedesign
- Posts: 71
- Joined: 14 Feb 2013 09:29
Script to do multiple pass rename
Thanks,
Sean Clarke
Sean Clarke
-
highend
- Posts: 15003
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script to do multiple pass rename
Code: Select all
// Do not separate your "odd" chars from another!
$oddChars = "δζ";
foreach($item, <get SelectedItemsNames |>) {
$item = recase($item, "l");
$base = gpc($item, "base");
$ext = "." . gpc($item, "ext");
$new = replacelist($base, " _$oddChars", "-") . $ext;
if ($new != $item) { renameitem($new, $item); }
}
One of my scripts helped you out? Please donate via Paypal
-
jaywalker32
- Posts: 214
- Joined: 27 May 2014 05:24
Re: Script to do multiple pass rename
what is the ._ notation used for in "._$oddChars" ?
-
highend
- Posts: 15003
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script to do multiple pass rename
A typo
The dot should have been a space...
One of my scripts helped you out? Please donate via Paypal
-
jaywalker32
- Posts: 214
- Joined: 27 May 2014 05:24
Re: Script to do multiple pass rename
but still, why is it not:
replacelist($base, $oddChars, "-")
Do the quotes and underscore around $oddChars serve a special case?
replacelist($base, $oddChars, "-")
Do the quotes and underscore around $oddChars serve a special case?
-
highend
- Posts: 15003
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script to do multiple pass rename
By default I wouldn't call a space or an underscore an "odd char"
So he should define his real "odd chars" inside the variable $oddChars
And the replaclist() will then replace the combined ones alltogether
So he should define his real "odd chars" inside the variable $oddChars
And the replaclist() will then replace the combined ones alltogether
One of my scripts helped you out? Please donate via Paypal
-
jaywalker32
- Posts: 214
- Joined: 27 May 2014 05:24
Re: Script to do multiple pass rename
ooh! I was overthinking it. I didn't realize that he also wanted to replace space and underscore with hyphen as well.
-
clarkedesign
- Posts: 71
- Joined: 14 Feb 2013 09:29
Re: Script to do multiple pass rename
OK, so how can I then assign it to the right hand mouse menu or a menu item or a keyboard shortcut ??
Thanks,
Sean Clarke
Sean Clarke
-
highend
- Posts: 15003
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Script to do multiple pass rename
Not possibleto the right hand mouse menu or a menu item
Menu - User - Manage Commands - Run Script or Load Script File?keyboard shortcut
One of my scripts helped you out? Please donate via Paypal
XYplorer Beta Club