-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlinks.py
More file actions
39 lines (31 loc) · 812 Bytes
/
links.py
File metadata and controls
39 lines (31 loc) · 812 Bytes
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
import os
import os.path
import pathlib
SIZES = [
16,
20,
24,
32,
40,
48,
56,
'decor',
]
def main():
for size in SIZES:
recurse(str(size))
def recurse(path):
print(f'Visiting {path}')
with os.scandir(path) as scanner:
for entry in scanner:
if entry.is_dir():
recurse(entry.path)
elif entry.name.endswith('.png') and entry.is_symlink():
target = os.readlink(entry.path)
# print(f'{entry.name} -> {target}')
try:
os.symlink(os.path.basename(target).replace('.png', '.webp'), entry.path.replace('.png', '.webp'))
except:
pass
if __name__ == '__main__':
main()