文件路径
C:\Users\XXXXX\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets
**其中加粗字体为电脑系统名和保存的随机地址(每台电脑可能会不一样)
import os
import time
from_path = "C:\\Users\\XXXXX\\AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets" #注意反斜杠的使用,替换掉路径内计算机名
to_path = "C:\\Users\\XXXXX\\Desktop\\fig_temp" #注意反斜杠的使用,替换掉路径内计算机名
os.mkdir(to_path) #在桌面上创建fig_temp的文件夹
day = time.strftime("%Y-%m-%d", time.gmtime()) #防止用户另存储时文件重名
os.chdir(from_path) #更改程序操作路径
fileList = os.listdir() #列出所有文件,列表格式
for fname in fileList: #复制from_path路径的文件至fig_temp文件夹
with open(from_path + "\\" + fname, "rb") as f:
temp = f.read()
with open(to_path + "\\" + fname,"wb+") as t:
t.write(temp)
os.chdir(to_path) #更改程序操作路径
fileList = os.listdir()
for i in range(len(fileList)):
newname = day + "_" + str(i+1) + ".jpg"
os.rename(fileList[i], newname) #更改文件名
版权声明:本文为weixin_40572034原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。