#!/usr/bin/python # # $ find files | bytime.py # # Sorts a file list, by time. Oldest first, recent last. # import sys import os import os.path import stat def run(filenames): bydir = { } for fname in filenames: d = os.path.dirname(fname) if d not in bydir: bydir[d] = set() bydir[d].add(fname) info = [ ] for d, s in bydir.items(): if len(s) > 1: ### for specific usage # if a directory has more than one video, skip it continue for fname in s: s = os.stat(fname) info.append((s.st_mtime, fname)) for t, fname in sorted(info): print(fname) if __name__ == '__main__': run(f.strip() for f in sys.stdin.readlines())