Special renaming box - missing add numberring (1) if the same name after renaming

Features wanted...
Post Reply
Radim
Posts: 12
Joined: 30 May 2019 19:47

Special renaming box - missing add numberring (1) if the same name after renaming

Post by Radim »

Hello,
I tried XYP and I see it very useful for me,
I need enhace this feature:
Image

when renaming some video files with Chinese and Rusian characters in filename. Many times the result is: ".mp4" (all chars was removed) and with more files like that same are not renamed.
It is possible to add into this dialog box a [x] check box that append automaticaly numbering to such cases (for duplicate filenames only)?

So if I have more expected results as:
".mp4"

it will produce:
"(1).mp4"
"(2).mp4"
"(3).mp4"
...etc.

Otherwise it needs one more renaming before processing this (as stated above).

Thank you. Radim

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Special renaming box - missing add numberring (1) if the same name after renaming

Post by highend »

What not using a script...

Works on all selected files...

Code: Select all

    $index = 1;
    foreach($item, <get SelectedItemsPathNames |>, , "e") {
        $name = trim(replace(RemoveUnicode(gpc($item, "base")), "¤"));
        $ext  = gpc($item, "ext");
        if ($name == "") {
            $name = "($index)." . $ext;
            $index++;
        } else {
            $name = $name . "." . $ext;
        }
        renameitem($name, $item);
    }

function RemoveUnicode($string) {
    $newString = "";

    $len = strlen($string);
    while ($i++ < $len) {
        $ascii = Asc(gettoken($string, $i, ""));
        if ($ascii >= 256) { $char = "¤"; }
        else { $char = chr($ascii); }
        $newString .= $char;
    }
    return $newString;
}
One of my scripts helped you out? Please donate via Paypal

Radim
Posts: 12
Joined: 30 May 2019 19:47

Re: Special renaming box - missing add numberring (1) if the same name after renaming

Post by Radim »

highend wrote: 31 May 2019 11:43 What not using a script...

Works on all selected files...

Code: Select all

    $index = 1;
    foreach($item, <get SelectedItemsPathNames |>, , "e") {
        $name = trim(replace(RemoveUnicode(gpc($item, "base")), "¤"));
        $ext  = gpc($item, "ext");
        if ($name == "") {
            $name = "($index)." . $ext;
            $index++;
        } else {
            $name = $name . "." . $ext;
        }
        renameitem($name, $item);
    }

function RemoveUnicode($string) {
    $newString = "";

    $len = strlen($string);
    while ($i++ < $len) {
        $ascii = Asc(gettoken($string, $i, ""));
        if ($ascii >= 256) { $char = "¤"; }
        else { $char = chr($ascii); }
        $newString .= $char;
    }
    return $newString;
}
Thanks, how to install it as icon on toolbar? I am new to XYP.

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Special renaming box - missing add numberring (1) if the same name after renaming

Post by highend »

Menu - Tools - Customize Toolbar...

Add a "User Button #<x>" from the left side to the right side

Right click that new button in the toolbar, "Edit..."

"Edit..." button at the right side "On left click", paste the script in that new window...
One of my scripts helped you out? Please donate via Paypal

Radim
Posts: 12
Joined: 30 May 2019 19:47

Re: Special renaming box - missing add numberring (1) if the same name after renaming

Post by Radim »

highend wrote: 31 May 2019 13:20 Menu - Tools - Customize Toolbar...

Add a "User Button #<x>" from the left side to the right side

Right click that new button in the toolbar, "Edit..."

"Edit..." button at the right side "On left click", paste the script in that new window...
Hmm, I did as you recomend, but when click on button with selected files nothing happens. :eh:

highend
Posts: 13327
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Special renaming box - missing add numberring (1) if the same name after renaming

Post by highend »

Use the script of my previous post again, I made a small update to it...
One of my scripts helped you out? Please donate via Paypal

Post Reply