Sequential renaming

is there a way to make sequential renaming skip files with existing numbers

i made a script to rename images inside a folder to folder name followed by a sequential number
(\d{13}).(jpg|jpeg|gif|png)
../{parent1}/{parent1}_[#].{ext}

this generates names like
subfolder_001.jpg
subfolder_002.jpg
subfolder_003.jpg
subfolder_004.jpg
subfolder_005.jpg

if i now want to rename some new files that it put in that folder it wants to start with "subfolder_001.jpg" again. is there a way that it continues with "subfolder_006.jpg" instead?

This script should let you do that:

[ul][li]Add a Unique Number while renaming.[/li][/ul]

thanks, but there is still a little problem:
there are not only jpg images but also some pngs. the script only checks for identical filenames but not for identical numbers. So this generates images with the same name but a different extension.