Rename script

Discuss and share scripts and script files...
gialandra
Posts: 28
Joined: 03 Feb 2019 14:12

Re: Rename script

Post by gialandra »

It works like a charm! Thanks boy for your help.

Now I need a beer to cool my brain and I want to offer a beer to you too! Thank you again.

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

Re: Rename script

Post by highend »

No problem and thanks for the beer :beer:
One of my scripts helped you out? Please donate via Paypal

gialandra
Posts: 28
Joined: 03 Feb 2019 14:12

Re: Rename script

Post by gialandra »

Sometimes the script stops its run and it needs a second launch. Seems that if in the working folder there isn't files beginning for 0 it stops. In there a way to move on searching for the first number and beginning the rename work from there?

Code: Select all

    $folder = "C:\Users\MN\Downloads\4S\1\";
    $files = listfolder($folder, , 1+4, <crlf>);
    $i = 0;
    while ($i < 10) {
        $selection = regexmatches($files, "^$i.*?(?=\r?\n|$)", <crlf>);
        if ($selection) {
            $j = 1;
            foreach($item, $selection, <crlf>, "e") {
                $number = format($j, "0000");
                renameitem($i . $number, $folder . $item, 1);
                $j++;
            }
        }
        $i++;
    }
    

gialandra
Posts: 28
Joined: 03 Feb 2019 14:12

Re: Rename script

Post by gialandra »

Maybe I have solved it: the script beginns the rename work too soon: I have add the line "wait 2000;" and all seems OK

More eleganly, is there a way of tell the script to wait for the completion of the previous operation before going forward?

Post Reply