-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindowsSpotlight.py
41 lines (34 loc) · 1.25 KB
/
WindowsSpotlight.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
from platform import system
from traceback import print_exc
from PIL import Image
from win10toast import ToastNotifier
def main():
global saved_counter
imgs_dir = os.path.join(
os.environ['USERPROFILE'],
'AppData\\Local\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets'
)
# destination = os.path.join(os.environ['USERPROFILE'], 'Desktop\\Windows SpotLight Images')
destination = 'Windows SpotLight Images'
file_list = os.listdir(imgs_dir)
if not os.path.exists(destination):
# os.chdir(os.path.join(os.environ['USERPROFILE'], 'Desktop'))
os.mkdir('Windows SpotLight Images')
for file in file_list:
with Image.open(os.path.join(imgs_dir, file)) as img:
if img.size == (1920, 1080):
img.save(os.path.join(destination, f'{file}.jpg'))
saved_counter += 1
if __name__ == '__main__' and system() == 'Windows':
try:
saved_counter = 0
main()
ToastNotifier().show_toast(
f"{saved_counter} images saved…!", "Windows Spotlight Images",
icon_path=''
)
except Exception as e:
print(e)
print_exc()
input('\nPress enter to exit.')