<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Life's End</title>
    <link>http://lifesend.com/</link>
    <description>Worship</description>
    <language>en-us</language>
    <item>
      <title>fmodlog</title>
      <description>&lt;!-- 
Found 0 labeled equations 
eq ids: 
--&gt;
&lt;!-- 
Found 0 figures 
fig ids: 
--&gt;
&lt;style type="text/css"&gt;pre.code {   background-color: #DDD;   color: #112;   padding: 10px;   font-size: 90%;   overflow: auto;   margin: 4px 0px;   width: 95%;}pre .normal {}pre .comment { color: #005; font-style: italic; }pre .keyword { color: #A00; font-weight: bold; }pre .method { color: #077; }pre .class { color: #074; }pre .module { color: #050; }pre .punct { color: #447; font-weight: bold; }pre .symbol { color: #099; }pre .string { color: #944; }pre .char { color: #F07; }pre .ident { color: #004; }pre .constant { color: #07F; }pre .regex { color: #B66; }pre .number { color: #F99; }pre .attribute { color: #5bb; }pre .global { color: #7FB; }pre .expr { color: #227; }pre .escape { color: #277; }div .aao_footer{ font-size: 80%; }&lt;/style&gt;
   &lt;div id=header&gt;
   &lt;h2&gt;Fmodlog&lt;/h2&gt;
Aaron Radke &lt;br&gt;
2007-11-26 &lt;br&gt;
&lt;em&gt;File modification tracking tool (this kind of tool was required before git)&lt;/em&gt;&lt;p&gt;
&lt;/div&gt;
Download: &lt;a href='/static/file/fmodlog.rb'&gt;fmodlog.rb&lt;/a&gt;&lt;pre class="prettyprint"&gt;
#!/usr/bin/ruby
#title:File Modification, backup and generation Log
#author:Aaron Radke
#date:2007-10-01
#		add include list
#date:2007-09-27
#		add skip_list
#		add dir_list
#		clean up the options file
#date: 2007-09-20
#		add file backup functions
#date: 2007-08-23
#  rubify for windows
#-------------
require 'find'
require 'fileutils'
   
#constants
HOME=ENV['userprofile']
LOG="#{HOME}/Library/Logs/fmodlog.log"
DIR_LIST = ["#{HOME}/Desktop","#{HOME}/My Documents","#{HOME}/bin"]
INCLUDE_LIST = ['\.rb$','\.aao$','\.txt','\.doc','\.ppt','\.html','\.vsd','\.xls','\.h','\.c','\.cpp','\.java','\.pde']
SKIP_LIST = ['\bTemp\b','\bLocal Settings','\bLogs\b','\.LOG$',"MS_HTML_Model_1_US_Only","no_sync"]
DO_BACKUP = true
BACKUP_DIR = "H:/backup"
PAUSE_MINUTES=5
   
      
def backup(filename)
   INCLUDE_LIST.each{|p|
      if filename =~ /#{p}/i
         copyToDateFolder(filename,BACKUP_DIR)
      end
   }
end
   
def copyToDateFolder(file,dir)
   now = Time.new()
   datestamp = now.strftime("%Y-%m-%d")
   date_dir = "#{dir}/#{datestamp}"
   if ! File.exists?(date_dir)
      Dir.mkdir(date_dir)
   end
   FileUtils.cp(file,date_dir)
end
   
      
puts "fmodlog.rb scanning every #{PAUSE_MINUTES} minutes..."
puts "==========="
pause_seconds = PAUSE_MINUTES*60
begin
   #init
   now = Time.new()
   datestamp = now.strftime("%Y-%m-%d %H:%M:%S")
   filecount = 0
   puts "------#{datestamp}----"
      
   logfile = File.open(LOG,"a")
   Find.find(*DIR_LIST) do |filename|
      SKIP_LIST.each{|p|
         if filename =~ /#{p}/i
            puts "Skip: #{filename}"
            Find.prune
            next
         end
      }
         
      if File.file?(filename)
         filecount = filecount.next
         file = File.stat(filename)
         if file.mtime &gt; (now - pause_seconds)
            puts "#{file.mtime.strftime("%Y-%m-%d %H:%M:%S")} #{filename}"
            logfile.puts "#{datestamp} #{filename}"
            backup(filename) if DO_BACKUP
         end
         # print "#{filecount}, " if filecount % 1000 == 0
      end
   end
   logfile.close
   puts "Sleeping #{PAUSE_MINUTES} minutes after checking #{filecount} files ..."
end while sleep(pause_seconds)
   
&lt;/pre&gt;
&lt;div class=aao_footer&gt;
&lt;hr&gt;

&lt;/div&gt;
</description>
      <author>Aaron Radke</author>
      <pubDate>Mon, 26 Nov 2007 15:23:04 +0000</pubDate>
      <link>&lt;a href="/feed/scripts"&gt;/fmodlog&lt;/a&gt;</link>
      <guid>&lt;a href="/feed/scripts"&gt;/fmodlog&lt;/a&gt;</guid>
    </item>
  </channel>
</rss>
