How to get alert from a diff output using python
<p>I am writing a python script to monitor changes in webpage. I have the diff command implemented in python and I have the diff output files in a folder. </p>

<p>I have 260 diff output files. Logically i cannot check all 260 to know which file has changes. </p>

<p>Is there a python solution to read all the diff files and alert me with the filenames which have the changes.</p>

<pre><code>sample filename in my diff output folder: ['4streaming', 'net-log-2016-09- 26-12:29:32']-diff-output-2016-09-27-13:07:32.html



Required output: 4streaming has changed
</code></pre>

<p>Forgive me if my way of asking question is wrong. I am new to stackoverflow forum wrt asking questions.</p>

<p>To check if two files have the same content you can use the <a href="https://docs.python.org/2/library/filecmp.html" rel="nofollow">filecmp</a> module:</p>

<pre><code>&gt;&gt;&gt; import filecmp
&gt;&gt;&gt; filecmp.cmp('a_file.txt', 'another_file.txt')
True
</code></pre>

<p>So in your case where you have a lot of files, you could store their names on a list (ex.File_list), and using <code>itertools</code> compare each item==file on the list only once with the others:</p>

<pre><code>import itertools
for i,j in itertools.combinations(File_list, 2):
    filecmp.cmp(i, j)   #where i,j are actual file names
    # do something based on the result
</code></pre>

<p>*To get a list with all the file names in a directory take a look at <a href="http://stackoverflow.com/questions/3207219/how-to-list-all-files-of-a-directory-in-python">this</a> post.</p>

<p>Another way would be by hashing them and comparing the hashes.</p>

python diff