Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import argparse, glob, sys, os, datetime, time, subprocess
- parser = argparse.ArgumentParser()
- parser.add_argument("src_path", metavar="path", type=str,
- help="Path to files to be merged; enclose in quotes, accepts * as wildcard for directories or filenames")
- args = parser.parse_args()
- files = glob.glob(args.src_path)
- def toDate(timestamp):
- return datetime.datetime.fromtimestamp(timestamp)
- def toTouchFormat(timestamp):
- date = datetime.datetime.fromtimestamp(timestamp)
- return date.strftime("%y%m%d0000")
- if not files:
- print('File does not exist: ' + args.src_path, file=sys.stderr)
- for file in files:
- print('File exists: ' + file)
- # path = Path(file)
- #last_modified = path.stat().st_mtime
- last_modified = int(os.stat(file).st_mtime)
- #created = path.stat().created
- created = int(os.stat(file).st_ctime)
- birthed = int(os.stat(file).st_birthtime)
- print('File birthed ' + str(toDate(birthed)))
- print('File created ' + str(toDate(created)))
- print('File modified ' + str(toDate(last_modified)))
- if birthed >= last_modified:
- print('would modify')
- program = 'touch -t ' + str(toTouchFormat(last_modified)) + ' ' + file
- print(program)
- process = subprocess.Popen(program.split(), stdout=subprocess.PIPE)
- output, error = process.communicate()
- print(output)
- print(error)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement