Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

windows batch script to duplicate files in an image sequence

I'm looking for a little help creating a batch rename script in windows

I have a folder of images, numbered sequentially by 3, ie.

  • test_01.001.tif
  • test_01.004.tif
  • test_01.007.tif

and so on

What i'm aiming to do is copy and rename each one twice so that it makes up the missing images after it, to make up the full image sequence, so that

test_01.001.tif is copied twice and those copies renamed to:

test_01.002.tif and test_01.003.tif

And so on for the rest of the image sequence (goes up to 200)

Any help much appreciated, thanks!

like image 839
Thomas Warrender Avatar asked May 14 '26 19:05

Thomas Warrender


1 Answers

Try this:

@echo off
setlocal EnableDelayedExpansion

for /F "tokens=1-3 delims=." %%a in ('dir /B /A-D *.*.tif') do (
   set /A new1=1%%b+1, new2=new1+1
   copy "%%a.%%b.%%c" "%%a.!new1:~1!.%%c"
   copy "%%a.%%b.%%c" "%%a.!new2:~1!.%%c"
)
like image 104
Aacini Avatar answered May 17 '26 16:05

Aacini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!