Help with a script

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

I need help in creating a script that renames my pictures according to the following diagram:
download/file.php?mode=view&id=14821

Thank you
Attachments
Automating selected files renaming.jpg
Automating selected files renaming.jpg (51.45 KiB) Viewed 1415 times

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

Re: Help with a script

Post by highend »

from a dropdown menu of selected names
?
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Help with a script

Post by Memyself »

This is group of 15 to 20 names that remain unchanged when the script is applied to the jpgs of a different folder.

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

Re: Help with a script

Post by highend »

I don't get it. Maybe someone else does...
One of my scripts helped you out? Please donate via Paypal

eil
Posts: 1622
Joined: 13 Jan 2011 19:44

Re: Help with a script

Post by eil »

he needs a script to rename images in folder by pattern:
[folder name]*space*name_picked_from_list
*name_picked_from_list =list of 15-20 strict specified names, kinda like tags. each cycle of script asks to pick one of names from list, for image currently under rename.
Win 7 SP1 x64 100% 1366x768

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

Re: Help with a script

Post by highend »

No, what I was wondering about is:
This is group of 15 to 20 names that remain unchanged
Ofc they are not changed, only items in the destination folder are to be renamed...

If this is not what you wanted, I'm out.

Code: Select all

    end (<get countselected> == 0), "No item(s) selected, aborted!";

    $dstFolder = inputfolder(, "Choose folder where the .jpg(s) reside");
    $jpgFiles  = listfolder($dstFolder, "*.jpg", 1+4, <crlf>);
    end (!$jpgFiles), "No .jpg file(s) found in destination folder, aborted!";

    $menu = regexreplace(<get SelectedItemsNames <crlf>>, "^(.+?)(\.[^.]+?)(?=\r?\n|$)", "$1");

    foreach($jpgFile, $jpgFiles, <crlf>, "e") {
        $tmpMenu = "Suffix for $jpgFile<crlf>-<crlf>" . $menu;
        $suffix  = popupmenu($tmpMenu, 6:=<crlf>, 7:="|");
        if (strpos($suffix, "suffix for") != -1) { continue; }
        $prefix  = gettoken($dstFolder, -1, "\");
        renameitem("$prefix $suffix", $jpgFile, 1, "-01");
    }
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Re: Help with a script

Post by Memyself »

Thank you for your reply.

Sorry my ignorance, but what type of file is SelectedItemsNames? Is it a text file that I have to create in the same folder where the jpgs' to be renamed are located? Is it a db file?

eil
Posts: 1622
Joined: 13 Jan 2011 19:44

Re: Help with a script

Post by eil »

Memyself wrote: 26 Jan 2021 05:32 Thank you for your reply.

Sorry my ignorance, but what type of file is SelectedItemsNames? Is it a text file that I have to create in the same folder where the jpgs' to be renamed are located? Is it a db file?
it's a command that gathers names of all selected files.
Win 7 SP1 x64 100% 1366x768

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Re: Help with a script

Post by Memyself »

I am assuming the names I want to use to rename the jpgs are contained in a txt or db file in the same folder where the jpgs' are located. My question was: which type of file shall the names be stored in, so as to be picked up by the SelectedItemsNames command ?

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

Re: Help with a script

Post by highend »

Selected names^^

You select the files you want to use as names for the .jpgs (in a different folder) and then you start the script...
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Re: Help with a script

Post by Memyself »

Thank you. The script works as per my functional diagram.

However, my objective was not totally reflected in it. A minor variation I would like to introduce is the possibility of skipping renaming of some of the jpgs when the script runs through them. Is it possible to achieve it by a small modification of the script?

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

Re: Help with a script

Post by highend »

Not with a popup menu...

This would work with skipped files:

Code: Select all

    end (<get countselected> == 0), "No item(s) selected, aborted!";

    $dstFolder = inputfolder(, "Choose folder where the .jpg(s) reside");
    $prefix    = gettoken($dstFolder, -1, "\");
    $jpgFiles  = listfolder($dstFolder, "*.jpg", 1+4, <crlf>);
    end (!$jpgFiles), "No .jpg file(s) found in destination folder, aborted!";

    $menu = regexreplace(<get SelectedItemsNames <crlf>>, "^(.+?)(\.[^.]+?)(?=\r?\n|$)", "$1");

    foreach($jpgFile, $jpgFiles, <crlf>, "e") {
        $suffix = inputselect("Suffix for $jpgFile", $menu, <crlf>, 4+32+4096+8192+16384, "not_named", 400, 600);
        if ($suffix LikeI "not_named") { continue; }
        renameitem("$prefix $suffix", $dstFolder . "\" . $jpgFile, 1, "-01");
    }
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Re: Help with a script

Post by Memyself »

Script execution error.
The script is interrupted in line 4
Attachments
Script execution error.png
Script execution error.png (34.37 KiB) Viewed 1366 times

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

Re: Help with a script

Post by highend »

Copy the script a second time and do it again
One of my scripts helped you out? Please donate via Paypal

Memyself
Posts: 20
Joined: 25 Jan 2021 18:13

Re: Help with a script

Post by Memyself »

Wow, it works. Thank you very much, it will save me tons of time.

Post Reply