Find files/folders that are modified after a specific date in Python -


problem ; find files/folders changed after specific date directory structure , copy these location (as stated in title well) (:

by following ;

def mod():      """find files modified today, given file path."""      latest = 0      = time.strftime('%y-%m-%d', time.localtime())      dir = "/home/y33t/"      fname in os.listdir(dir):          if fname.endswith(''):              modtime = os.stat(os.path.join(dir, fname)).st_mtime              if modtime > latest:                  latest = modtime                  out = time.strftime('%y-%m-%d', time.localtime(latest))                  if out == now:                      print fname, "has changed today. "                  else:                      pass 

i can determine files changed @ specific date , copy these location. achieve keep directory structure well. example following ;

/testfolder ..somefile1 ..somefile2 ../testfolder2 ....somefile3 ....somefile4 

and on...

lets somefile3 changed @ specified date , save location while saving, cascaded directory structure should maintained well. how can achieve in elegant way ?

before copying, should solve reading. os.listdir give 1 level while os.walk let go on each file in every depth.

to copy, first use os.makedirs(target-path) create folders root target folder @ depth use shutil.copy copy file.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -