0

Pictures are generated in a directory, each with the same name. I would like to move them to another directory and rename them in an ascending order using a batch file,

e.g. bild1.png -> 1.png, next time bild1.png -> 2.png and so on.

Currently the generated file overwrites the existing file.

What do I have to write in the batch file so it looks in the new directory and renames it with the next number?

For now, the batch file looks like this:

cd C:\stable-diffusion\diffusers\examples\inference

move bild1.png "C:\stable-diffusion\diffusers\examples\inference\Stable Diffusion\"
Compo
  • 36,585
  • 5
  • 27
  • 39
nilros85
  • 1
  • 1

1 Answers1

0
cd C:\stable-diffusion\diffusers\examples\inference

SET "destdir=C:\stable-diffusion\diffusers\examples\inference\Stable Diffusion"
SET /a sequence=0
:nextseq
SET /a sequence+=1
IF EXIST "%destdir%\%seqence%.png" goto nextseq

move bild1.png "%destdir%\%seqence%.png"

Simply keep incrementing sequence until the destination filename does not already exist.

Magoo
  • 77,302
  • 8
  • 62
  • 84