How to correct the sequential number order for the selected files

Try:

Replace

If fs.FileExists(strTryNewFullPath) Or fs.FolderExists(strTryNewFullPath) Then

with

If (fs.FileExists(strTryNewFullPath) Or fs.FolderExists(strTryNewFullPath)) And (strTryNewFullPath <> fs.BuildPath(strFilePath, strFileName)) Then

This should implement the check Leo suggested and prevent files that happen to already have the right name to get a new one (not heavily tested).

And while you are at it: Change PadTo = "(2)" to PadTo = 2.

1 Like

Thanks lxp but I am sorry cause I am not enough skilled to edit this kinds of complex script. I it's my humble request for you, Leo or any one who can edit script Please edit this script.

Dear lxp, I have tried to replace in line no 144 with If (fs.FileExists(strTryNewFullPath) Or fs.FolderExists(strTryNewFullPath)) And (strTryNewFullPath <> fs.BuildPath(strFilePath, strFileName)) Then
and also replace line no. 31 with: PadTo = 2
then try to rename but Its show error as my screenshot

Please

  • generate a mirror of your music collection with this script or anything similar,
  • remove the stuff you don't want the world to see,
  • zip it and upload it (should be small enough)

so we can test properly.


Update 2021-07-29:

This script makes it even easier to generate the test cases.


I presume this is not related, or is it?

image