Optional removal of the original file added

This commit is contained in:
2026-07-28 17:35:44 +05:00
parent 12c359b973
commit ec3af18549
+18 -3
View File
@@ -91,9 +91,7 @@ def main():
help='Parse and display the tracklist without splitting any files' help='Parse and display the tracklist without splitting any files'
) )
# ------------------------------------------------------------ # Metadata options.
# Metadata options (new)
# ------------------------------------------------------------
parser.add_argument( parser.add_argument(
'--album', '--album',
help='Set album name in output metadata (overrides parsed %%al and original 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: "; ")' 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() args = parser.parse_args()
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
@@ -197,6 +202,16 @@ def main():
print(f"Error: {error}") print(f"Error: {error}")
sys.exit(1) 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!") print("Done!")