title: How to diff two folders to multiple patch files
body: <p>First, I tried asking the same on askubuntu and I'm not getting far there... 
  <a href="https://askubuntu.com/questions/186114/how-to-diff-two-folders-to-multiple-patch-files/186121#comment231985_186121">https://askubuntu.com/questions/186114/how-to-diff-two-folders-to-multiple-patch-files/186121#comment231985_186121</a></p>
  
  <p>So, i'll copy/paste here in hopes SO gives me a working solution...</p>
  
  <p>I'm not much of a unix guy so I'll just go ahead and ask:</p>
  
  <p>I have a following problem - two folders with plenty of subfolders. I need to diff them.</p>
  
  <p>I tried this:</p>
  
  <pre><code>diff -drupN vanila_kernel_3.0.8 my_kernel_3.0.8 &gt; kernel.patch
  </code></pre>
  
  <p>and that results in a 185mb file... and not really what I want.</p>
  
  <p>I want the result of the diff to be many smaller patches, ideally one for every changed file with the contents of the change. That means I have t ochange the way I use diff, and I need to put it in some sort of a loop... So i tried running this little script</p>
  
  <pre><code>for file in original_308/*.*; do
      diff -dupN "$file" "my_308/${file##*/}" &gt; "$file".patch
  done
  </code></pre>
  
  <p>But it doesn't work :/</p>
  
  <p>Ideally, I want to have a .patch file for every change, but having patches for files that changed in original would do just fine (as I could filter the newly added files and just copy them over)</p>
  
  <p>Can someone provide me with a decent way to do this please?</p>
  
  <p>UPDATE:
  I know there are 231 altered files between these folders and 4546 newly added files... I'm just interested in generating those 231 patches. I even have a file containing those 231 filenames so that can be used in a script as well.</p>
  
  <p>I used this to generate the changelog</p>
  
  <pre><code>diff -qdr -x *.o -x *.cmd -x *.d original_308 my_308 | sed "s/^.* and \(.*\) differ/\1/" | sort &gt; changes.txt
  </code></pre>
  
  <p>and that just prints the filenames that changed, trailed by "only in my_308" files... the 231 files are on the top of that file (the first 231 lines)</p>
  
  <p>So let's make it clear - I want .patch files for source files. If the patches can end up in patches//file_name.c.patch that would be really great...</p>
  
  <p>If you give me PERL scripts please tell me how to best use them since I do not understand that garbage. Please don't fail me SO. I need to get this thing ported, tested and running and I'm wasting time on unix commands and untangible scripts ffs.</p>