coerrace
asked on
command prompt rename files in sequential serie
Hello I want to order a serie of files I have in c:\data
file001.pdf
file002.pdf
file004.pdf
file007.pdf
file009.pdf
file010.pdf
and so on any number of files.
This files could be hundred and there are names that doesn't exist in sequence like file003.pdf, file005.pdf, etc. Now in command prompt what script could be to order in sequence all that files and the numbers of the fies doesn't exist will be taken for next files in sequence for example file003.pdf doesn't exist then file004.pdf will take the name of file003.pdf in our example file007.pdf will take the name of file004.pdf, file009.pdf will take the name of file005.pdf and so on until the end of files .pdf only. The final result pf all process will be in other words:
file001.pdf - not touched because is ok in order
file002.pdf - not touched because is ok in order
file004.pdf - renamed to file003.pdf
file007.pdf - renamed to file004.pdf
file009.pdf - renamed to file005.pdf
file010.pdf - renamed to file006.pdf
The final files ordered in resume:
file001.pdf
file002.pdf
file003.pdf
file004.pdf
file005.pdf
file006.pdf
If anyone could help with a command .bat script.
Thank you
file001.pdf
file002.pdf
file004.pdf
file007.pdf
file009.pdf
file010.pdf
and so on any number of files.
This files could be hundred and there are names that doesn't exist in sequence like file003.pdf, file005.pdf, etc. Now in command prompt what script could be to order in sequence all that files and the numbers of the fies doesn't exist will be taken for next files in sequence for example file003.pdf doesn't exist then file004.pdf will take the name of file003.pdf in our example file007.pdf will take the name of file004.pdf, file009.pdf will take the name of file005.pdf and so on until the end of files .pdf only. The final result pf all process will be in other words:
file001.pdf - not touched because is ok in order
file002.pdf - not touched because is ok in order
file004.pdf - renamed to file003.pdf
file007.pdf - renamed to file004.pdf
file009.pdf - renamed to file005.pdf
file010.pdf - renamed to file006.pdf
The final files ordered in resume:
file001.pdf
file002.pdf
file003.pdf
file004.pdf
file005.pdf
file006.pdf
If anyone could help with a command .bat script.
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi coerrace
You may have been left wondering why you received an email notification of a comment submitted before the one by oBdA. I started writing a batch file yesterday and had posted a "working on this" comment, but something came up and I had to leave what I was doing, so I deleted the comment and wasn't able to finish what I had started. oBdA's batch file is along the same lines as I was heading, but is much better.
Bill
You may have been left wondering why you received an email notification of a comment submitted before the one by oBdA. I started writing a batch file yesterday and had posted a "working on this" comment, but something came up and I had to leave what I was doing, so I deleted the comment and wasn't able to finish what I had started. oBdA's batch file is along the same lines as I was heading, but is much better.
Bill
ASKER
Oh I see honestly the first thing at the morning was see the oBdA I tested but never saw a working on this, but is ok.
Thank you for all
Thank you for all
ASKER
Amazing code!!!