windows - Terms matching in two files.txt, batch script -


first of, read /help , thread 1 : comparing 2 files in batch script

but chinese me.

i'm experienced in c/c++ programming (linux/unix) , i'm getting stuck batch script on ma dear windows.

here problem : have 2 files (file1.txt (or logok.txt in below source code) , file2.txt) looks like

file1.txt : dir1;dir2;dir3;dir4;...

file2.txt : dir7;dir3;dir4;dir1;...

(files aren't ordered name asc or whatever have ';' separator)

what want .bat compare file1.txt file2.txt , when match (here dir 1, 3 , 4) echo [folderx] >> file3.txt

so i'll file3.txt : dir1;dir2;dir3

here first part (wich works well, actually) of script check if directories empty or not, if can : (there 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%"  /d %%a in ("%folder%\*") (     set "size=0"     /f "tokens=3,5" %%b in ('dir /-c /a /w /s "%%~fa\*" 2^>nul ^| findstr /b /c:"  "') 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 help

@echo off setlocal enabledelayedexpansion  :: read in 2 lists  /f "delims=" %%a in (q26907961a.txt) set "list1=%%a" /f "delims=" %%a in (q26907961b.txt) set "list2=%%a"  :: bippity boppity boo  set "list1="%list1:;=";"%"" set "list2="%list2:;=";"%"" set "list3="  %%a in (%list1%) %%b in (%list2%) if %%a==%%b set "list3=!list3!;%%~a" set list3=%list3:~1%  set list  goto :eof 

i used files named q26907961a.txt , q26907961b.txt containing data testing.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -