mirror of
https://github.com/osmarks/random-stuff
synced 2025-12-22 21:47:00 +00:00
declassify some projects
This commit is contained in:
22
memeticize.py
Normal file
22
memeticize.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import os, sys, subprocess, datetime
|
||||
|
||||
dt_threshold = datetime.datetime(2022, 11, 27).timestamp()
|
||||
|
||||
_, indir, outdir = sys.argv
|
||||
for x in os.listdir(indir):
|
||||
inpath = os.path.join(indir, x)
|
||||
if os.stat(inpath).st_mtime > dt_threshold:
|
||||
if subprocess.run(("feh", inpath)).returncode == 0:
|
||||
newname = input(x + ": ")
|
||||
if newname:
|
||||
ctr = 1
|
||||
while True:
|
||||
newpath = os.path.join(outdir, newname + (f"-{ctr}" if ctr > 1 else "") + os.path.splitext(x)[1])
|
||||
if os.path.exists(newpath):
|
||||
print("already in use")
|
||||
ctr += 1
|
||||
else:
|
||||
os.rename(inpath, newpath)
|
||||
break
|
||||
else:
|
||||
print("keeping")
|
||||
Reference in New Issue
Block a user