Skip to content

Commit 73f9548

Browse files
committed
feat(new): add "for_games/Final Fantasy VII etc screenshots/"
1 parent 3f81c5e commit 73f9548

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = "ipetrash"
5+
6+
7+
from pathlib import Path
8+
9+
from PIL import Image
10+
11+
PATH_DIR: Path = Path(r"C:\Users\ipetrash\Desktop\FF7 Screenshots")
12+
PATH_DIR_CROPPED: Path = PATH_DIR / "cropped"
13+
14+
15+
for path in PATH_DIR.rglob("*.*"):
16+
if path.suffix.lower() not in [".png", ".jpg", ".jpeg"]:
17+
continue
18+
19+
path_img_cropped: Path = PATH_DIR_CROPPED / path.name
20+
if path_img_cropped.exists():
21+
continue
22+
23+
img = Image.open(path)
24+
width, height = img.size
25+
if width <= 2560:
26+
continue
27+
28+
if width == 4480:
29+
x1 = 1920
30+
y1 = 0
31+
x2 = width
32+
y2 = height
33+
34+
img_cropped = img.crop((x1, y1, x2, y2))
35+
crop_width, crop_height = img_cropped.size
36+
37+
print(
38+
f"Cropping image {width}x{height} -> {crop_width}x{crop_height} "
39+
f'from "{path}" to "{path_img_cropped}"'
40+
)
41+
42+
path_img_cropped.parent.mkdir(parents=True, exist_ok=True)
43+
img_cropped.save(path_img_cropped)
44+
45+
continue
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = "ipetrash"
5+
6+
7+
from pathlib import Path
8+
9+
10+
for path in Path(r"C:\Users\ipetrash\Desktop\FF7 Screenshots").rglob("*.*"):
11+
if not path.is_file():
12+
continue
13+
14+
if path.suffix.lower() not in [".jpg", ".jpeg"]:
15+
continue
16+
17+
new_name: str = f"{path.stem}.png"
18+
19+
new_path: Path = path.parent / new_name
20+
if path.name == new_path.name:
21+
continue
22+
23+
print(f'Renaming "{path}" to "{new_path.name}"')
24+
path.rename(new_path)
25+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
__author__ = "ipetrash"
5+
6+
7+
import re
8+
from pathlib import Path
9+
10+
FILE_PATTERN: re.Pattern = re.compile(r"^(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})-\d+ \((\d+)\)$")
11+
12+
# NOTE: "2026-09-17_04-34-08-647679 (1).png" -> "2026-09-17_04-34-08-000001.png"
13+
# NOTE: "2026-09-17_04-34-08-647679 (2).jpg" -> "2026-09-17_04-34-08-000002.jpg"
14+
for path in Path(r"C:\Users\ipetrash\Desktop\FF7 Screenshots").rglob("*.*"):
15+
if not path.is_file():
16+
continue
17+
18+
m: re.Match | None = FILE_PATTERN.match(path.stem)
19+
if not m:
20+
continue
21+
22+
new_name: str = f"{m.group(1)}-{m.group(2).zfill(6)}{path.suffix}"
23+
24+
new_path: Path = path.parent / new_name
25+
if path.name == new_path.name:
26+
continue
27+
28+
print(f'Renaming "{path}" to "{new_path.name}"')
29+
path.rename(new_path)

0 commit comments

Comments
 (0)