title: Prefix filename with LasWriteTime based on filetype
body: <p>Trying to append the lastwrite time (last file content modification time) timestamp into the filename of <strong>select media filetypes</strong> only, from different camera models. The pattern would be: <code>YYYYMMDD_HHMMSS__origfilename.ext</code>.</p>
  
  <p>For example, <strong>before</strong> and <strong>after</strong> the rename:</p>
  
  <pre><code>origfilename.jpg             &gt;   20011231_235959__origfilename.jpg
  origfilename2.png            &gt;   origfilename2.png     #.txt is not a "media_file"
  </code></pre>
  
  <p>The filetypes to timestamp are defined in a nested dictionary and called with <code>config[camID]["media_file"]</code> for each camera type :</p>
  
  <p><strong>Code</strong> (last line gives syntax error):</p>
  
  <pre><code>config = {
      'nd5': {},
      'g7': {},
      'alpha9': {},
  }
  config['nd5']['media_file'] = ('nef', 'jpg', 'avi')
  config['g7']['media_file'] = ('cr2', 'jpg', 'mp4')
  config['alpha9']['media_file'] = ('jpg')    
  
  root = "."     
  def get_last_write_time(filename):
      st = os.stat(filename)
      convert_time_to_human_readable = time.strftime("%Y%m%d_%H%M%S", time.localtime(st.st_mtime))
      return convert_time_to_human_readable
  
  timestr = convert_time_to_human_readable
  
  for camID in config:
      for dir in next(os.walk(root))[1]:
          if dir.endswith(camID):
              for path, dirs, files in os.walk(os.path.join(root, dir)):
                  for f in files:
                      if any([f.lower().endswith(x) for x in config[camID]["media_file"]]):
                          os.rename(os.path.join(path, f) 
                          os.path.join(path, "%s" % timestr+'_'+f))
  </code></pre>
  
  <p>Tree showing the =camID (=key1, the string after the last <code>=</code> in the directory name) and the filetypes to append timestamp:</p>
  
  <pre><code>└───CWD
      ├───001=nd5
      │   └───DCIM
      │       ├───125NCD5     ('nef', 'jpg', 'avi')
      │       ├───126NCD5     ('nef', 'jpg', 'avi')
      │       └───127NCD5     ('nef', 'jpg', 'avi')
      ├───002=nd5
      │   └───DCIM
      │       ├───201NCD5     ('nef', 'jpg', 'avi')
      │       ├───202NCD5     ('nef', 'jpg', 'avi')
      │       └───203NCD5     ('nef', 'jpg', 'avi')
      ├───003=g7
      │   └───DCIM
      │       ├───112___09    ('cr2', 'jpg', 'mp4')
      │       └───112___10    ('cr2', 'jpg', 'mp4')
      └───004=alpha9
          ├───DCIM
          │   └───101MSDCF    ('jpg')
          └───PRIVATE
              ├───AVCHD
              │   └───BDMV
              │       ├───CLIPINF
              │       ├───PLAYLIST
              │       └───STREAM      
              └───SONY
  </code></pre>