Batch append on several photos with "paired" postfix in Windows
Posted: 2015-05-06T05:32:21-07:00
Hi.
I have a directory with two sets of images. The postfix of these files are matched in pairs, such as Top_0001.png,Top_0002.png,Bottom_0001.png,Bottom_0002.png. The output of these four files should be Combined_0001 and Combined_0002.
In reality, the postfix is random and there will be several thousand files to process.
Input_Top
Input_Bottom
Output
What would be the easiest way to append these images in a batch file? I have managed to google together something that works, but I do not quite understand WHY and HOW it works. Any comments are appreciated.
I have a directory with two sets of images. The postfix of these files are matched in pairs, such as Top_0001.png,Top_0002.png,Bottom_0001.png,Bottom_0002.png. The output of these four files should be Combined_0001 and Combined_0002.
In reality, the postfix is random and there will be several thousand files to process.
Input_Top
Input_Bottom
Output
What would be the easiest way to append these images in a batch file? I have managed to google together something that works, but I do not quite understand WHY and HOW it works. Any comments are appreciated.
Code: Select all
@echo off
:: setLocal EnableDelayedExpansion
set targetdir="C:\temp"
set setnum=0
for /f "tokens=2 delims=_." %%a in ('dir /b /o-n %targetdir%\Top*.png') do convert %targetdir%\Top_%%a.png %targetdir%\Bottom_%%a.png -append %targetdir%\Combined_%%a.png