Created
September 20, 2017 08:36
-
-
Save takemitsu/72c1c1883129db5f1a153190782d796c to your computer and use it in GitHub Desktop.
日付ファイルのコピー(python)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import os.path | |
| import datetime | |
| import shutil | |
| import sys | |
| pwd = os.getcwd() | |
| if pwd != '/Users/takemitsu/work/': | |
| sys.exit(1) | |
| today = datetime.date.today() | |
| today = today + datetime.timedelta(days=-1) | |
| path = 'test_' + today.isoformat() + '.log' | |
| if os.path.exists(path) == False: | |
| sys.exit(2) | |
| for x in range (300): | |
| date = today + datetime.timedelta(days = -1 * x) | |
| path2 = 'test_' + date.isoformat() + '.log' | |
| if os.path.exists(path2) == False: | |
| shutil.copyfile(path, path2) | |
| sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment