args_parser.add_argument('-src', '--src', type=str, nargs='?', default='.', help='(OPTIONAL) Directory where files will be moved from. Defaults to current directory')
args_parser.add_argument('-dst', '--dst', type=str, nargs='?', required=True, help='(REQUIRED) Directory where files will be moved to.')
args_parser.add_argument('-days', '--days', type=int, nargs='?', default=240, help='(OPTIONAL) Days value specifies the minimum age of files to be moved. Default is 240.')
args=args_parser.parse_args()
ifargs.days<0:
args.days=0
src=args.src# Set the source directory
dst=args.dst# Set the destination directory
days=args.days#Set the number of days
now=time.time() # Get the current time
ifnotos.path.exists(dst):
os.mkdir(dst)
forfinos.listdir(src): # Loop through all the files in the source directory
ifos.stat(f).st_mtime<now-days*86400: # Work out how old they are, if they are older than 240 days old