Page 1 of 1

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

Posted: 31 May 2019 11:13
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

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

Posted: 31 May 2019 11:43
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;
}

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

Posted: 31 May 2019 13:16
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.

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

Posted: 31 May 2019 13:20
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...

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

Posted: 31 May 2019 13:55
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:

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

Posted: 31 May 2019 14:14
by highend
Use the script of my previous post again, I made a small update to it...