filemtime - Python script must take a backup from recently modified directories but fails in reading mtime -


i wrote script below checks specified path parent_dir , finds modified directories (+subdirectories) makes of them move_dir

the problem i'm struggling that, seems script, somehow, doesn't check mtime of directories , copies whole content within parent directory destination address. doing wrong here?

import os import os.path import datetime shutil import copytree shutil import move time import time os.chdir("/home/sina/desktop/incoming")  def mins_since_mod(fname):     """return time last modification in minutes"""     return (time() - os.path.getmtime(fname)) / 60 parent_dir = '/home/sina/desktop/incoming' move_dir = '/home/sina/desktop/incoming_new'  # loop on files in parent_dir fname in os.listdir(parent_dir):     # if file directory , modified in last 10 days         if ((os.path.isdir(fname)) , (mins_since_mod(fname) < 14400)):            copytree(fname, move_dir) # move new location 

if want make question more clear, can consider path below folowing subdirectoris:

 /home/sina/desktop/incoming/a/a1.1  /home/sina/desktop/incoming/a/a2.2  ... 

the subdirectories within ../a such a2.2 or a1.1 being modified app (this app may add new subdirectories) , i'd have of them every 10 days @ path /home/sina/desktop/incoming_new/a/{subdirectories}

any kind of appreciated.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -