I am trying to parse a multi-line output and struggling with a few things. I'm trying to write a script that will execute the 'diff' command and identify files that have been modified or added to a core project. There script accepts 2 input parameters for the top level of the master repository and the top level of the modified project. The code is:
for /f "delims=" %%a in ('diff -qr "%path1%" "%path2%"') do ( SET output=%%a echo a:%%a echo output:%output% ... )
The first problem I'm having is that the output from this is:
a:Only in <filename>
the SET output command does not seem to assign the variable the value. This is making processing the output a challenge. What I'd like to do is separate the diff results into different lists. The diff utility generates 3 possible output:
- Only in <path1 filename>
- Files <path1 filename> and <path2 filename> differ
- Only in <path2 filename>
I'm trying to identify which type of output the output string belongs to and then to strip out only the file name for the path1 files, but the code I've used before to test for contained strings doesn't work with the %%a variable; i.e.
SET newFile=Only^ in^ if NOT "x%%a:%newFile%=%% == "x%%a%%" do ...
Any help is appreciated. Thanks