Last active
November 7, 2019 06:45
-
-
Save TTTPOB/5f05c6dc99599ab0e6dac1f157f36e20 to your computer and use it in GitHub Desktop.
OneDrive for android will backup all photos, screenshots and saved pictures into the same folder. and if you use CHN as system language, it will save the photo in a CHN-named folder(图片) not “Picture”. This python script (recommended run in wsl) helps to solve this problem.
This file contains 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 | |
from datetime import date | |
import glob | |
today=date.today() | |
for x in list(range(1, today.month+1)): | |
year=str(today.year) | |
# year='2018' | |
month=format(x, '02d') | |
# Photo | |
os.system(r'mkdir -p 本机照片/' + year + r'.' + month) | |
PhotoFileList=glob.glob("本机照片/IMG_"+year+month+"*") | |
PhotoFileList+=glob.glob("本机照片/PANO_"+year+month+"*") | |
PhotoFileList+=glob.glob("本机照片/VID_"+year+month+"*") | |
# PhotoFileList+=glob.glob("本机照片/"+year+month+"*") | |
for File in PhotoFileList: | |
try: | |
os.system("mv "+File+" 本机照片/"+year+r"."+month) | |
except: | |
print("Something went wrong") | |
# Screenshot | |
ScreenshotList=glob.glob("本机照片/Screenshot_"+year+"-"+month+"*") | |
ScreenshotList+=glob.glob("本机照片/Screenrecord*"+year+"-"+month+"*") | |
ScreenshotList+=glob.glob("本机照片/Screenshot_*"+year+month+"*") | |
os.system(r'mkdir -p 屏幕快照/' + year + r'.' + month) | |
for screenshot in ScreenshotList: | |
try: | |
os.system("mv "+screenshot+" 屏幕快照/"+year+r"."+month) | |
except: | |
print("Something went wrong") | |
os.system("mv 本机照片/* " + os.path.join('..','Pictures',r'Camera\ Roll')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment