The following batch will do the job Code: @echo off setlocal enabledelayedexpansion set /a n=1 for /f "tokens=*" %%A IN ('"dir /b C:\oldfiles"') do ( call :for2 !n! "%%A" set /a n=!n!+1 ) pause exit :for2 set str=%2 set str=%str:~1,-1% for /f "skip=%1 tokens=*" %%a IN ('"dir /b C:\newfiles"') do echo %str% %%a & exit /b Eg. file structure Code: C:\>dir /b C:\oldfiles 0 - Copy (2).txt 0 - Copy (3).txt 0 - Copy (4).txt 0 - Copy (5).txt 0 - Copy (6).txt 0 - Copy (7).txt 0 - Copy (8).txt 0 - Copy (9).txt 0 - Copy.txt 0.txt C:\>dir /b C:\newfiles 1 - Copy (10).txt 1 - Copy (2).txt 1 - Copy (3).txt 1 - Copy (4).txt 1 - Copy (5).txt 1 - Copy (6).txt 1 - Copy (7).txt 1 - Copy (8).txt 1 - Copy (9).txt 1 - Copy.txt 1.txt Output of above batch Code: 0 - Copy (2).txt 1 - Copy (2).txt 0 - Copy (3).txt 1 - Copy (3).txt 0 - Copy (4).txt 1 - Copy (4).txt 0 - Copy (5).txt 1 - Copy (5).txt 0 - Copy (6).txt 1 - Copy (6).txt 0 - Copy (7).txt 1 - Copy (7).txt 0 - Copy (8).txt 1 - Copy (8).txt 0 - Copy (9).txt 1 - Copy (9).txt 0 - Copy.txt 1 - Copy.txt 0.txt 1.txt Press any key to continue . . . 1 - Copy (10).txt is an additional file in newfiles folder. It is a dummy file that needs to be on top of the list so that the second for loop runs as expected.
Code: @echo off setlocal enabledelayedexpansion set /a n=1 for /f "tokens=*" %%A IN (oldfilelist.txt) do ( call :for2 !n! %%A set /a n=!n!+1 ) exit :for2 for /f "skip=%1 tokens=*" %%a IN (newfilelist.txt) do echo %2 %%a & exit /b Change the highlighted part to bspatch syntax.
%2 is the name of the old file %%a is the name of the file to be compared What do you want the third file name to be? H:\My Data\My Programs\Windows\Microsoft\Microsoft Office 2010\Crack\My Tools\Channel Switch\patched\*.patched
I think this will do it Code: @echo off setlocal enabledelayedexpansion set /a n=1 for /f "tokens=*" %%A IN (oldfilelist.txt) do ( call :for2 !n! %%A set /a n=!n!+1 ) pause exit :for2 for /f "skip=%1 tokens=*" %%a IN (newfilelist.txt) do ( set str=%%a set str=!str:~0,-1!.patched" bspatch %2 %%a !str! exit /b )
The newfilelist.txt has empty line in the beginning. There are exactly 76 lines in the oldfilelist and 77 lines in the newfilelist. If you look at the second for loop you will notice that I skip a number of lines and process only the first line and break from the loop. If you try to echo the three file names you will get exactly 76 lines of output. Its good that you got it working in another way. Can you post your batch file here?