선택한 이미지들을 드래그하고 폴더에 드롭하면 파일 이동 실행

This commit is contained in:
2026-05-15 16:31:58 +09:00
parent 595ceac26b
commit 604c1aa806
6 changed files with 283 additions and 11 deletions
+33
View File
@@ -36,6 +36,39 @@ function register() {
}
});
ipcMain.handle('check-files-exist', (_event, folderPath, names) => {
return names.filter(name => {
try { fs.accessSync(path.join(folderPath, name)); return true; }
catch { return false; }
});
});
ipcMain.handle('move-files', async (_event, { targetFolder, files }) => {
const errors = [];
const moved = [];
for (const file of files) {
const destName = file.newName || file.name;
const dest = path.join(targetFolder, destName);
try {
fs.renameSync(file.path, dest);
moved.push({ src: file.path, dest, name: destName });
} catch (e) {
if (e.code === 'EXDEV') {
try {
fs.copyFileSync(file.path, dest);
fs.unlinkSync(file.path);
moved.push({ src: file.path, dest, name: destName });
} catch (e2) {
errors.push(`${file.name}: ${e2.message}`);
}
} else {
errors.push(`${file.name}: ${e.message}`);
}
}
}
return { moved, errors };
});
ipcMain.handle('rename-files', async (_event, { folderPath, files, prefix, digits }) => {
const errors = [];
const pad = (n) => String(n + 1).padStart(digits, '0');