每周都需要写周报,每次都需要复制周报模板,自己动手码了一个Python自动复制周报模板的工具,按照年度归档文件夹
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Aiker Zhao
# @Date : 2020/8/11 6:17 下午
# @File : create_week_log.py
# @Desc :
import os
import time
import copyfile
from datetime import datetime
week_now = int(time.strftime(‘%W‘)) + 1
timenow=datetime.now().strftime(‘%Y-%m-%d %H:%M:%S‘)
theyear = str(datetime.today().year)
# print(theyear)
print(timenow + "" + " 本周是" + theyear +"年第" + str(week_now) + "周")
# print(week_now)
log_model = ‘周报模板.md‘
log_file = str(week_now) + ‘周.md‘
f_path = ‘/Users/Aiker/Documents/onedrive/gitnote/xxx/周报/‘
file_path = os.path.join(f_path, str(theyear))
if not os.path.exists(file_path):
os.mkdir(file_path)
else:
pass
if not os.path.isfile(os.path.join(file_path, log_file)):
copyfile.copyFile(os.path.join(f_path, log_model), os.path.join(file_path, log_file))
print("新的周报文件已经创建好了... ")
else:
print("周报文件已经存在了哦,无需新建。")
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.create.weeklog.auto</string>
<key>ProgramArguments</key>
<array>
<string>/Users/Aiker/PycharmProjects/pacong3/venv/bin/python</string>
<string>/Users/Aiker/PycharmProjects/pacong3/create_week_log.py</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/Users/Aiker/Documents/onedrive/gitnote/wonders/周报/org.create.weeklog.auto.log</string>
<key>StandardOutPath</key>
<string>/Users/Aiker/Documents/onedrive/gitnote/wonders/周报/org.create.weeklog.auto.log</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>9</integer>
<key>Minute</key>
<integer>10</integer>
</dict>
</dict>
</plist>
launchctl load ~/Library/LaunchAgents/org.create.weeklog.auto.plist
原文:https://blog.51cto.com/m51cto/2675484