else/Toolbox/touch.py

19 lines
403 B
Python
Raw Normal View History

2016-12-05 01:50:52 +00:00
'''
Create the file, or update the last modified timestamp.
'''
2016-11-18 06:24:52 +00:00
import glob
import os
import sys
glob_patterns = sys.argv[1:]
for glob_pattern in glob_patterns:
filenames = glob.glob(glob_pattern)
if len(filenames) == 0:
print(glob_pattern)
open(glob_pattern, 'a').close()
else:
for filename in filenames:
print(filename)
os.utime(filename)