mirror of
https://github.com/kevinveenbirkenbach/duplicate-file-handler.git
synced 2024-11-14 18:11:03 +01:00
solved apply to bug
This commit is contained in:
parent
1384a5451f
commit
f5c7a945c5
28
main.py
28
main.py
@ -34,18 +34,24 @@ def handle_file_modification(original_file, duplicate_file, modification):
|
|||||||
print(f"Replaced {duplicate_file} with a symlink to {original_file}")
|
print(f"Replaced {duplicate_file} with a symlink to {original_file}")
|
||||||
|
|
||||||
def handle_modification(files, modification, mode, apply_to):
|
def handle_modification(files, modification, mode, apply_to):
|
||||||
original_file = files[0] # Keep the first file
|
original_file = next((f for f in files if not f.startswith(tuple(apply_to))), files[0])
|
||||||
for duplicate_file in files[1:]: # Iterate over remaining files
|
for duplicate_file in files:
|
||||||
if duplicate_file.startswith(tuple(apply_to)):
|
if duplicate_file != original_file:
|
||||||
if mode == 'preview' and modification != 'show':
|
if duplicate_file.startswith(tuple(apply_to)):
|
||||||
print(f"Would perform {modification} on {duplicate_file}")
|
if mode == 'preview':
|
||||||
elif mode == 'act':
|
print(f"Would perform {modification} on {duplicate_file}")
|
||||||
handle_file_modification(original_file, duplicate_file, modification)
|
elif mode == 'act':
|
||||||
elif mode == 'interactive':
|
|
||||||
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)
|
handle_file_modification(original_file, duplicate_file, modification)
|
||||||
print()
|
elif mode == 'interactive':
|
||||||
|
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):
|
def main(args):
|
||||||
directories = args.directories
|
directories = args.directories
|
||||||
|
Loading…
Reference in New Issue
Block a user