title: Batch file to search for string and return line
body: <p>I know very basic (Windows) batch scripting, and this is way out of my league - hopefully I can get some help here.</p>
  
  <p>I have multiple text files of the same file name in folders with the naming convention yyyy-mm (eg. C:\folder\yyyy-mm\file.txt)</p>
  
  <p>I would like to write a script to go into all file.txt, search for a unique ID in the file always at the beginning of the line (may or may not recur in the different months), return/append the folder name (yyyy-mm) at the front of the whole line that matches the search into a new text file, and move on to the next month. </p>
  
  <p>ie.</p>
  
  <blockquote>
    <p>C:\folder\2014-05\file.txt contains line "ID123 foo bar" among other lines</p>
    
    <p>C:\folder\2014-05\file.txt contains line "ID123 bar foo" among other lines</p>
    
    <p>output file for a search on ID123 would be</p>
    
    <p>2014-04 ID123 foo bar</p>
    
    <p>2014-05 ID123 bar foo</p>
  </blockquote>
  
  <p>Would this be simpler with some other language? I am familiar with Excel VBA, but not quite so with filesystemobjects within VB. </p>
  
  <p>There are no other sub-folders to be concerned of, so I am not worried about recognizing the correct sub-folders and just do loop over all sub-folders.</p>
  
  <p>Thank you.</p>