First of, I read some /help and thread like this one : Comparing two files in batch script
but this is chinese to me.
I'm experienced in C/C++ programming only (Linux/UNIX) and I'm getting stuck for a batch script on ma dear windows.
Here the problem : I have two files (file1.txt (or logOK.txt in the below source code) and file2.txt) which looks like
file1.txt : dir1;dir2;dir3;dir4;...
file2.txt : dir7;dir3;dir4;dir1;...
(files aren't ordered by name ASC or whatever but they all have a ';' as separator)
What I want my .bat to do is to compare file1.txt to file2.txt and when something match (here dir 1, 3 and 4) it will echo [folderX] >> file3.txt
so I'll get a file3.txt : dir1;dir2;dir3
Here is the first part (wich works well, actually) of the script which check if the directories are empty or not, if it can help : (there is some debugs lines too)
@echo off
setlocal disabledelayedexpansion
if exist logKO.txt del /s logKO.txt
if exist logOK.txt del /s logOK.txt
set "folder=."
if not defined folder set "folder=%cd%"
for /d %%a in ("%folder%\*") do (
set "size=0"
for /f "tokens=3,5" %%b in ('dir /-c /a /w /s "%%~fa\*" 2^>nul ^| findstr /b /c:" "') do if "%%~c"=="" set "size=%%~b"
setlocal enabledelayedexpansion
if !size! EQU 0 echo %%~nxa; >> logKO.txt
if !size! NEQ 0 echo(%%~nxa # !size!
if !size! NEQ 0 echo/| set /p = "%%~nxa;" >> logOK.txt
endlocal
)
endlocal
Thanks for help