Page 1 of 3

Help with a script

Posted: 25 Jan 2021 23:03
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

Re: Help with a script

Posted: 25 Jan 2021 23:07
by highend
from a dropdown menu of selected names
?

Help with a script

Posted: 25 Jan 2021 23:14
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.

Re: Help with a script

Posted: 25 Jan 2021 23:21
by highend
I don't get it. Maybe someone else does...

Re: Help with a script

Posted: 26 Jan 2021 00:26
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.

Re: Help with a script

Posted: 26 Jan 2021 01:09
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");
    }

Re: Help with a script

Posted: 26 Jan 2021 05:32
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?

Re: Help with a script

Posted: 26 Jan 2021 08:18
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.

Re: Help with a script

Posted: 26 Jan 2021 16:49
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 ?

Re: Help with a script

Posted: 26 Jan 2021 17:10
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...

Re: Help with a script

Posted: 26 Jan 2021 18:03
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?

Re: Help with a script

Posted: 26 Jan 2021 18:26
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");
    }

Re: Help with a script

Posted: 26 Jan 2021 18:45
by Memyself
Script execution error.
The script is interrupted in line 4

Re: Help with a script

Posted: 26 Jan 2021 18:56
by highend
Copy the script a second time and do it again

Re: Help with a script

Posted: 26 Jan 2021 19:48
by Memyself
Wow, it works. Thank you very much, it will save me tons of time.