From 98ff495e10c3500a302bf8c1de87092989f3f66f Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 15 Feb 2023 13:42:59 +0800 Subject: [PATCH] improve concat output filename extension handling --- src/components/ConcatDialog.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/ConcatDialog.jsx b/src/components/ConcatDialog.jsx index 6cb934df..92cedb87 100644 --- a/src/components/ConcatDialog.jsx +++ b/src/components/ConcatDialog.jsx @@ -77,7 +77,10 @@ const ConcatDialog = memo(({ return; } const ext = getOutFileExtension({ isCustomFormatSelected, outFormat: fileFormat, filePath: firstPath }); - setOutFileName(getSuffixedFileName(firstPath, `merged-${uniqueSuffix}${ext}`)); + setOutFileName((existingOutputName) => { + if (existingOutputName == null) return getSuffixedFileName(firstPath, `merged-${uniqueSuffix}${ext}`); + return existingOutputName.replace(/(\.[^.]*)?$/, ext); // make sure the last (optional) .* is replaced by .ext` + }); }, [fileFormat, firstPath, isCustomFormatSelected, uniqueSuffix]); const allFilesMeta = useMemo(() => {