最近在使用backiee,可以自动设置每日壁纸,但是壁纸无法自动保存,所以尝试使用Python脚本解决。

Python脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#-*- coding: utf-8 -*-
import os
import shutil

address = 'C:/Users/sky/AppData/Local/Packages/35010GOOD2CREATE.LIVELOCKTHEMES_cxjy25q2av1xg/LocalState/' # 需要遍历的目录
dest = 'D:/Users/sky/Pictures/Saved Pictures' # 目标位置
n = 0

for folder, sub_folders, files in os.walk(address): # 遍历指定目录

if files: # 如果文件列表不是空的
#print('the files in ' + folder + ':')
for file in files:
# print(file)
if file.endswith('.jpg'): # 查找以jpg为后缀的文件
n += 1 # 计数
source = os.path.join(folder, file) # 原文件路径名
destination = os.path.join(dest, file) # 目标文件路径名
new_dest = shutil.copy(source, destination) # 拷贝
#print('source is ' + source)
#print('destination is ' + destination)
print('the copy : ' + new_dest) # 拷贝文件的路径

print('the number of copies = ', n) # 总拷贝数
print('over!')

Windows自动任务

创建Windows自动任务

注意:直接设置启动.py脚本Windows会弹出窗口,可以改为.pyw即可避免弹窗。