I scoured the web and could not find the exact code I’m looking for… I found things that are very similar but did not get them to work. Here is a rough idea what I want:
int i = 1;
FOR (i; i < 9999; i++)
IF EXIST filename.log THEN
REN filename%i%.log
ELSE IF EXIST filename%i%.log THEN
REN filename%(i+1)%.log
Basically I want to check if a filename exists and if so, rename it to filename0001 — from there on, each time the batch is run, if filename#### is found, it renames it to one after that. So of course after the first time this is run, when it finds that filename exists it will rename it to filename0002 and so on.
Thank you!!
Edited in response to comment. Also added test to make sure debug.log exists. Don’t want to rename files unnecessarily
This 1st solution always has the most recent log as debug.log, the next most recent as debug0001.log, the next as debug0002.log, etc. The oldest log will have the highest number.
To make the oldest log have 0001 and the newest have the highest number, then a small change is needed. Only one rename is needed.