Bugfixes for all programs

This commit is contained in:
Olivier 'reivilibre' 2021-04-09 14:21:37 +01:00
parent 52e58ba505
commit df3e79b9e6
3 changed files with 14 additions and 5 deletions

View File

@ -40,7 +40,7 @@ def cli():
pattern = re.compile(args.pattern)
for filename in sys.argv[3:]:
for filename in args.files:
base = os.path.basename(filename)
dirn = os.path.dirname(filename)
new_base = pattern.sub(args.replacement, base)

View File

@ -20,9 +20,13 @@ def get_new_name(filename, date_matches):
while True:
if suffix == 0:
target = f"{dirn}/{year}-{month}-{date}_{hour}:{second}:{minute}{extension}"
target_base = f"{year}-{month}-{date}_{hour}:{second}:{minute}{extension}"
else:
target = f"{dirn}/{year}-{month}-{date}_{hour}:{second}:{minute}_{suffix}{extension}"
target_base = (
f"{year}-{month}-{date}_{hour}:{second}:{minute}_{suffix}{extension}"
)
target = os.path.join(dirn, target_base)
if not os.path.exists(target):
return target
@ -74,7 +78,9 @@ def cli():
found_raw = unextended + ".CR2"
else:
unextended_basename = os.path.basename(unextended)
try_next = os.path.dirname(filename) + "/CR2/" + unextended_basename
try_next = os.path.join(
os.path.dirname(filename), "CR2", unextended_basename + ".CR2"
)
if os.path.exists(try_next):
found_raw = try_next

View File

@ -28,7 +28,7 @@ def prepare_processable(search_in: str):
found_raw = unextended + ".CR2"
else:
unextended_basename = os.path.basename(unextended)
try_next = os.path.dirname(file) + "/CR2/" + unextended_basename
try_next = os.path.join(os.path.dirname(file), "CR2", unextended_basename + ".CR2")
if os.path.exists(try_next):
found_raw = try_next
@ -86,6 +86,9 @@ def cli():
print("<phototrie.py> [file extension to process e.g. CR2 or jpg.")
print("keybinds: B 'bad', 'G' good, 'P' pristine")
if len(sys.argv) < 2:
sys.exit(1)
to_process, tmp_dir = prepare_processable(".")
dirs = "./bad", "./good", "./pristine"