Miscellaneous - Questions

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 26 May 2019 14:45

Wow, works great, thanks a lot once again.
$inc = "-" . format($startNum + $i, 000) . "-";
You mean like this? Is this method right, isn't it?

highend
Posts: 8376
Joined: 06 Feb 2011 00:33

Re: Miscellaneous - Questions

Post by highend » 26 May 2019 14:52

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...
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 26 May 2019 14:59

Yeah! I see its like this "000" in the doc. :tup:

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 31 Jul 2019 20:01

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

highend
Posts: 8376
Joined: 06 Feb 2011 00:33

Re: Miscellaneous - Questions

Post by highend » 31 Jul 2019 20:06

renameitem(regexreplace(<curbase>, "\..+$"));
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 31 Jul 2019 20:12

You are just awesome. Thanks a lot.

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 01 Aug 2019 14:04

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++; }

highend
Posts: 8376
Joined: 06 Feb 2011 00:33

Re: Miscellaneous - Questions

Post by highend » 01 Aug 2019 14:28

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"); }
        }
    }
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 01 Aug 2019 14:59

That is what I wanted. Thanks again.

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 01 Aug 2019 17:51

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.

highend
Posts: 8376
Joined: 06 Feb 2011 00:33

Re: Miscellaneous - Questions

Post by highend » 01 Aug 2019 18:00

And?

Use the last script and modify it accordingly.

A working regex could look like this:
$name = regexreplace($item, "^(.*?)(_Male|_Female)(.*?$)", "$1$2");
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 01 Aug 2019 18:26

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"); }
        }
    }

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 02 Aug 2019 11:46

Any help?
Can't make it run.

highend
Posts: 8376
Joined: 06 Feb 2011 00:33

Re: Miscellaneous - Questions

Post by highend » 02 Aug 2019 11:58

*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);
    }
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

MaxEnrik
Posts: 80
Joined: 20 Apr 2019 02:34

Re: Miscellaneous - Questions

Post by MaxEnrik » 02 Aug 2019 23:09

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

Post Reply