파일 이름 변경 내용에 접미사 추가

This commit is contained in:
2026-05-22 08:02:51 +09:00
parent f3193672c6
commit 77bc2815a3
7 changed files with 23 additions and 9 deletions
+3 -2
View File
@@ -92,9 +92,10 @@ function register() {
return { restored, errors };
});
ipcMain.handle('rename-files', async (_event, { folderPath, files, prefix, digits }) => {
ipcMain.handle('rename-files', async (_event, { folderPath, files, prefix, digits, postfix = '' }) => {
const errors = [];
const pad = (n) => String(n + 1).padStart(digits, '0');
const suffix = postfix ? `_${postfix}` : '';
// 1단계: 임시 이름으로 이동 (충돌 방지)
const tmpMap = [];
@@ -113,7 +114,7 @@ function register() {
// 2단계: 최종 이름으로 이동
const renamed = [];
for (const { tmp, ext, idx } of tmpMap) {
const newName = `${prefix}_${pad(idx)}${ext}`;
const newName = `${prefix}_${pad(idx)}${suffix}${ext}`;
const dest = path.join(folderPath, newName);
try {
fs.renameSync(tmp, dest);