From ec3af185491ea7bfe21950ed1b961506acf3202c Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Tue, 28 Jul 2026 17:35:44 +0500 Subject: [PATCH] Optional removal of the original file added --- audio_splitter/main.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/audio_splitter/main.py b/audio_splitter/main.py index 257cdb6..535cc47 100644 --- a/audio_splitter/main.py +++ b/audio_splitter/main.py @@ -91,9 +91,7 @@ def main(): help='Parse and display the tracklist without splitting any files' ) - # ------------------------------------------------------------ - # Metadata options (new) - # ------------------------------------------------------------ + # Metadata options. parser.add_argument( '--album', help='Set album name in output metadata (overrides parsed %%al and original album)' @@ -124,6 +122,13 @@ def main(): help='Separator used when merging comments (default: "; ")' ) + # NEW: Delete original after successful split. + parser.add_argument( + '--delete-original', + action='store_true', + help='Delete the original input file after successful splitting (default: keep)' + ) + args = parser.parse_args() # -------------------------------------------------------------------------- @@ -197,6 +202,16 @@ def main(): print(f"Error: {error}") sys.exit(1) + # -------------------------------------------------------------------------- + # Delete original file if requested and successful. + # -------------------------------------------------------------------------- + if args.delete_original: + try: + os.remove(args.input_file) + print(f"Deleted original file: {args.input_file}") + except OSError as e: + print(f"Warning: Could not delete original file: {e}") + print("Done!")