init
This commit is contained in:
29
NeedTranslate/gpt-o4.py
Normal file
29
NeedTranslate/gpt-o4.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
import shutil
|
||||
import re
|
||||
|
||||
ch4F = "./ch4"
|
||||
files = os.listdir(ch4F)
|
||||
prefixes = {f[:-6] for f in files if f.endswith("_1.png")}
|
||||
|
||||
for prefix in prefixes:
|
||||
dest_dir = os.path.join(ch4F, prefix)
|
||||
os.makedirs(dest_dir, exist_ok=True)
|
||||
for fname in list(files):
|
||||
if fname.startswith(prefix + "_") or fname == f"{prefix}.png":
|
||||
shutil.move(os.path.join(ch4F, fname),
|
||||
os.path.join(dest_dir, fname))
|
||||
files = os.listdir(ch4F)
|
||||
|
||||
pattern0 = re.compile(r"^(.+)_0\.png$")
|
||||
for fname in files:
|
||||
m = pattern0.match(fname)
|
||||
if not m:
|
||||
continue
|
||||
prefix = m.group(1)
|
||||
variants = [f for f in files if f.startswith(prefix + "_") and f != fname]
|
||||
if not variants:
|
||||
src = os.path.join(ch4F, fname)
|
||||
dst = os.path.join(ch4F, f"{prefix}.png")
|
||||
os.rename(src, dst)
|
||||
files = os.listdir(ch4F)
|
||||
Reference in New Issue
Block a user