mirror of
https://github.com/kevinveenbirkenbach/duplicate-file-handler.git
synced 2024-11-22 05:51:03 +01:00
solved apply to bug
This commit is contained in:
parent
1384a5451f
commit
f5c7a945c5
12
main.py
12
main.py
@ -34,10 +34,11 @@ def handle_file_modification(original_file, duplicate_file, modification):
|
||||
print(f"Replaced {duplicate_file} with a symlink to {original_file}")
|
||||
|
||||
def handle_modification(files, modification, mode, apply_to):
|
||||
original_file = files[0] # Keep the first file
|
||||
for duplicate_file in files[1:]: # Iterate over remaining files
|
||||
original_file = next((f for f in files if not f.startswith(tuple(apply_to))), files[0])
|
||||
for duplicate_file in files:
|
||||
if duplicate_file != original_file:
|
||||
if duplicate_file.startswith(tuple(apply_to)):
|
||||
if mode == 'preview' and modification != 'show':
|
||||
if mode == 'preview':
|
||||
print(f"Would perform {modification} on {duplicate_file}")
|
||||
elif mode == 'act':
|
||||
handle_file_modification(original_file, duplicate_file, modification)
|
||||
@ -45,8 +46,13 @@ def handle_modification(files, modification, mode, apply_to):
|
||||
answer = input(f"Do you want to {modification} this file? {duplicate_file} [y/N] ")
|
||||
if answer.lower() in ['y', 'yes']:
|
||||
handle_file_modification(original_file, duplicate_file, modification)
|
||||
else:
|
||||
print(f"Duplicate file (unmodified): {duplicate_file}")
|
||||
else:
|
||||
print(f"Original file kept: {original_file}")
|
||||
print()
|
||||
|
||||
|
||||
def main(args):
|
||||
directories = args.directories
|
||||
apply_to = args.apply_to or directories
|
||||
|
Loading…
Reference in New Issue
Block a user