|Provided your "file A" will contain the numbers then it should work:|
FOR /F "USEBACKQ DELIMS=" %%A IN ("C:\PATH\TO\FILE_A.TXT") DO (
>NUL FIND "%%A" "C:\PATH\TO\FILE_B.TXT"||>>"NEWFILE" ECHO %%A
FOR /F ....
Loop over the text output of a file command or string exchanging the current token(chunk of text).
These are options for the for /f loop I used, the are however others. "USEBACKQ" tells the for /f loop that the meaning of the quote characters should use the "new" sematics, where double quotes enclose file names(important for file names with spaces or ampersands).
"delims=" tells the for loop to split up the text on the delimiters right of the equals sign and before the double quote, leaving it blank means the text won't be split up.
... %%A ...
This is the for loop variable it can be any letter(among other characters), is case sensitive and is only valid within the for loop. It will contain the lines/tokens on at a time.
This simply tells the for loop we will be iterating over the file.
The code block(inside parentheses)will be executed once for every line/token of text.
>NUL FIND "%%A" "C:\PATH\TO\FILE_B.TXT"
A couple of things are being done here, the ">nul" basically says "discard all output" and the find command is looking for the text held in the variable "%%A" in the text file. Find will leave an errorlevel(return code) of zero if it finds the string and one if it doesen't.
The double pipe means "if the command to the left returned an errorlevel greater than zero execute the command to the right"
>>"NEWFILE" ECHO %%A
This command only gets executed if the find returned an errorlevel greater than zero. the ">>" means append the out put of the command to and "newfile" is a text file, echo simply outputs the text in %%a.
Batch Variable how to