"""
python 自动复制U盘文件到电脑磁盘v202112012250
打包exe去黑框:pyinstaller -F -w D:\a1.py
"""
import pathlib
import time
import datetime
import shutil # pip install pytest-shutil
import os
usb_path = "g:/oCam"
while 1:
date = str(datetime.datetime.now())[0:16]
date = date.replace('-', '').replace(' ', '').replace(':', '')
# print(date)
save_path = 'D:/照片/' + date
if pathlib.Path(usb_path).exists():
pass
if not pathlib.Path(save_path).exists():
if shutil.copytree(usb_path, save_path):
os.startfile(save_path) # 打开文件夹窗口
if not pathlib.Path(usb_path).exists():
pass
time.sleep(1)
|