diff --git a/src/components/OutSegTemplateEditor.jsx b/src/components/OutSegTemplateEditor.jsx
index 15c0ae81..02dc8cee 100644
--- a/src/components/OutSegTemplateEditor.jsx
+++ b/src/components/OutSegTemplateEditor.jsx
@@ -8,7 +8,7 @@ import { IoIosHelpCircle } from 'react-icons/io';
import Swal from '../swal';
import HighlightedText from './HighlightedText';
-import { defaultOutSegTemplate } from '../util/outputNameTemplate';
+import { defaultOutSegTemplate, segNumVariable } from '../util/outputNameTemplate';
import useUserSettings from '../hooks/useUserSettings';
const ReactSwal = withReactContent(Swal);
@@ -115,12 +115,14 @@ const OutSegTemplateEditor = memo(({ outSegTemplate, setOutSegTemplate, generate
- {error != null &&
{i18n.t('There is an error in the file name template:')} {error}
}
+ {error != null &&
{i18n.t('There is an error in the file name template:')} {error}
}
+
{isMissingExtension &&
{i18n.t('The file name template is missing {{ext}} and will result in a file without the suggested extension. This may result in an unplayable output file.', { ext: extVar })}
}
+
{`${i18n.t('Variables')}:`}
electron.shell.openExternal('https://github.com/mifi/lossless-cut/blob/master/import-export.md#customising-exported-file-names')} />
- {['FILENAME', 'CUT_FROM', 'CUT_TO', 'SEG_NUM', 'SEG_LABEL', 'SEG_SUFFIX', 'EXT', 'SEG_TAGS.XX', 'EPOCH_MS'].map((variable) => (
+ {['FILENAME', 'CUT_FROM', 'CUT_TO', segNumVariable, 'SEG_LABEL', 'SEG_SUFFIX', 'EXT', 'SEG_TAGS.XX', 'EPOCH_MS'].map((variable) => (
onVariableClick(variable)}>{variable}
))}
diff --git a/src/util/outputNameTemplate.js b/src/util/outputNameTemplate.js
index 95779b6b..44495f70 100644
--- a/src/util/outputNameTemplate.js
+++ b/src/util/outputNameTemplate.js
@@ -6,6 +6,8 @@ import isDev from '../isDev';
import { getSegmentTags } from '../segments';
+export const segNumVariable = 'SEG_NUM';
+
const { parse: parsePath, sep: pathSep, join: pathJoin, normalize: pathNormalize } = window.require('path');
// eslint-disable-next-line import/prefer-default-export
@@ -57,7 +59,7 @@ export function getOutSegError({ fileNames, filePath, outputDir, safeOutputFileN
if (error != null) return error;
- if (hasDuplicates(fileNames)) return i18n.t('Output file name template results in duplicate file names (you are trying to export multiple files with the same name.)');
+ if (hasDuplicates(fileNames)) return i18n.t('Output file name template results in duplicate file names (you are trying to export multiple files with the same name). You can fix this for example by adding the "{{segNumVariable}}" variable.', { segNumVariable });
return undefined;
}
@@ -93,7 +95,7 @@ function formatSegNum(segIndex, segments) {
}
export function generateOutSegFileNames({ segments, template, forceSafeOutputFileName, formatTimecode, isCustomFormatSelected, fileFormat, filePath, safeOutputFileName, maxLabelLength }) {
- const currentTimestamp = Date.now();
+ const epochMs = Date.now();
return segments.map((segment, i) => {
const { start, end, name = '' } = segment;
@@ -114,7 +116,7 @@ export function generateOutSegFileNames({ segments, template, forceSafeOutputFil
const segFileName = interpolateSegmentFileName({
template,
- epochMs: currentTimestamp + i, // for convenience: give each segment a unique timestamp
+ epochMs,
segNum,
inputFileNameWithoutExt,
segSuffix: getSegSuffix(),