Page 3 of 8

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:45
by MaxEnrik
Wow, works great, thanks a lot once again.
$inc = "-" . format($startNum + $i, 000) . "-";
You mean like this? Is this method right, isn't it?

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:52
by highend
The 000 should be quoted. style is a string. I know it works but this could change with any new version if XY would be a little less forgiving...

Re: Miscellaneous - Questions

Posted: 26 May 2019 14:59
by MaxEnrik
Yeah! I see its like this "000" in the doc. :tup:

Re: Miscellaneous - Questions

Posted: 31 Jul 2019 20:01
by MaxEnrik
I'd like to remove this part of name '.aaa-00_05_23_31-72563' with script.
Real Folder Name: 'Name Surname 01963.aaa-00_05_23_31-72563'

There is screenshot.
Image

Re: Miscellaneous - Questions

Posted: 31 Jul 2019 20:06
by highend
renameitem(regexreplace(<curbase>, "\..+$"));

Re: Miscellaneous - Questions

Posted: 31 Jul 2019 20:12
by MaxEnrik
You are just awesome. Thanks a lot.

Re: Miscellaneous - Questions

Posted: 01 Aug 2019 14:04
by MaxEnrik
Folders have only single file inside the folder. (Very rarely 2 files can be in the folders.)
So I just need to files get Folder names with script.

Image

Expecting results with script.
Car Showcase 00063.mp4
Food Desert 00759.mp4


This code from @highend
I just tweaked but doesn't work if I select multiple folders. I have to do one by one with below edited code.

Code: Select all

    $parent = gpc(<curitem>, "base", -2, 1);
    $itemsInside = listfolder(<curitem>, , 4);
    while ($i++ < gettoken($itemsInside, "count", "|"))
    {   $item = gettoken($itemsInside, $i, "|");
        renameitem("$parent." . gpc($item, "ext"), "<curitem>\$item"); }
    end true;

    $parent = gpc(<curitem>, "component", -2, 1);
    $i = 1;
    foreach($item, listfolder(<curitem>, , 4), , "e")
    {   renameitem("$parent - $i." . gpc($item, "ext"), "<curitem>\$item");
        $i++; }

Re: Miscellaneous - Questions

Posted: 01 Aug 2019 14:28
by highend
Then you have to use a foreach loop?

Code: Select all

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        if (exists($folder) != 2) { continue; }
        $parent = gpc($folder, "base", -2, 1);
        $filesInside = listfolder($folder, , 4);
        $i = 0;
        while ($i++ < gettoken($filesInside, "count", "|")) {
            $file = gettoken($filesInside, $i, "|");
            $newName = "$parent." . gpc($file, "ext");
            if (exists("$folder\$newName") == 1) { renameitem($newName, "$folder\$file", 16); }
            else { renameitem($newName, "$folder\$file"); }
        }
    }

Re: Miscellaneous - Questions

Posted: 01 Aug 2019 14:59
by MaxEnrik
That is what I wanted. Thanks again.

Re: Miscellaneous - Questions

Posted: 01 Aug 2019 17:51
by MaxEnrik
I would like to do this with script.

This is original version:
Name_Surname_02739_Male_20_Artist
Name_Surname_00063_Female_10_Musician

Expecting result:
Name Surname 02739 Male
Name Surname 00063 Female

Thanks in advance.

Re: Miscellaneous - Questions

Posted: 01 Aug 2019 18:00
by highend
And?

Use the last script and modify it accordingly.

A working regex could look like this:
$name = regexreplace($item, "^(.*?)(_Male|_Female)(.*?$)", "$1$2");

Re: Miscellaneous - Questions

Posted: 01 Aug 2019 18:26
by MaxEnrik
I tried below one but didn't worked. I am worrying that I didn't understand correctly.

Code: Select all

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        if (exists($folder) != 2) { continue; }
        $parent = gpc($folder, "base", -2, 1);
        $filesInside = listfolder($folder, , 4);
        $i = 0;
        while ($i++ < gettoken($filesInside, "count", "|")) {
            $file = gettoken($filesInside, $i, "|");
            // $newName = "$parent." . gpc($file, "ext");
            $name = regexreplace($item, "^(.*?)(_Male|_Female)(.*?$)", "$1$2");
            if (exists("$folder\$name") == 1) { renameitem($name, "$folder\$file", 16); }
            else { renameitem($name, "$folder\$file"); }
        }
    }

Re: Miscellaneous - Questions

Posted: 02 Aug 2019 11:46
by MaxEnrik
Any help?
Can't make it run.

Re: Miscellaneous - Questions

Posted: 02 Aug 2019 11:58
by highend
*sigh*

Code: Select all

    foreach($folder, <get SelectedItemsPathNames |>, , "e") {
        if (exists($folder) != 2) { continue; }
        $base = gpc($folder, "base", -2, 1);
        $newName = replace(regexreplace($base, "^(.*?)(_Male|_Female)(.*?$)", "$1$2"), "_", " ");
        renameitem($newName, $folder);
    }

Re: Miscellaneous - Questions

Posted: 02 Aug 2019 23:09
by MaxEnrik
I tried over 40 mins to modify this single line and make it run properly but still nothing.

Code: Select all

        $newName = replace(regexreplace($base, "^(.*?)(_Male|_Female)(.*?$)", "$1$2"), "_", " ");
I just need result could be like this:
Name Surname 02739
Name Surname 00063