Rename slow on collision

Discuss and share scripts and script files...
Post Reply
Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Rename slow on collision

Post by Caz »

In a script I have a command to rename files and overwrite on collision.
I use the rename command with flag 128.
In case there is no collision, the process is immediate.
In case there are some collisions, the process takes time.
You can try by duplicating files and renaming it to original names.

Code: Select all

rename r, "-01\. > .",,,128 ;
Any idea why ?

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

Re: Rename slow on collision

Post by highend »

Takes 150ms to rename
New Textfile-01.txt
...
New Textfile-20.txt

to:
New Textfile.txt

with

Code: Select all

rename "r", "-\d{2}\. > .",4:=128;
7,5ms per rename. Can't say that it is incredible slow
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Rename slow on collision

Post by Caz »

Is there a command to measure the time the command takes to execute ?
How long does it take on your test if there is no collision ?

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

Re: Rename slow on collision

Post by highend »

Is there a command to measure the time the command takes to execute ?

Code: Select all

    $start = now("msecs");
    rename "r", "-\(d{2})\. > 0$1.",4:=128;
    status "Time: " . now("msecs") - $start . " msecs";
How long does it take on your test if there is no collision ?
You mean something like this?

Code: Select all

rename "r", "-(\d{2})\. > 0$1.",4:=128;
50ms
One of my scripts helped you out? Please donate via Paypal

Caz
Posts: 35
Joined: 31 Oct 2018 09:12

Re: Rename slow on collision

Post by Caz »

If I test renaming 32 files of 2Mo : 2500ms with collisions, 187ms without collision.
[Edit] Same processing times with files of 160ko.

Post Reply