mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
✨ Feature: now prompts if there are duplicate file names
This commit is contained in:
parent
d6df9bcaf4
commit
8ba46d9272
@ -1254,7 +1254,7 @@ https://www.baidu.com/img/bd_logo1.png"
|
|||||||
@close="() => {
|
@close="() => {
|
||||||
isSingleRename = false
|
isSingleRename = false
|
||||||
isRenameIncludeExt = false
|
isRenameIncludeExt = false
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<el-link
|
<el-link
|
||||||
:underline="false"
|
:underline="false"
|
||||||
@ -1353,7 +1353,7 @@ https://www.baidu.com/img/bd_logo1.png"
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</span>
|
</span>
|
||||||
</el-link>
|
</el-link>
|
||||||
<br />
|
<br>
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="isRenameIncludeExt"
|
v-model="isRenameIncludeExt"
|
||||||
active-text="是"
|
active-text="是"
|
||||||
@ -2588,6 +2588,7 @@ async function BatchRename () {
|
|||||||
for (let i = 0; i < matchedFiles.length; i++) {
|
for (let i = 0; i < matchedFiles.length; i++) {
|
||||||
matchedFiles[i].newName = matchedFiles[i].newName.replaceAll('{auto}', (i + 1).toString())
|
matchedFiles[i].newName = matchedFiles[i].newName.replaceAll('{auto}', (i + 1).toString())
|
||||||
}
|
}
|
||||||
|
const duplicateFilesNum = matchedFiles.filter((item: any) => matchedFiles.filter((item2: any) => item2.newName === item.newName).length > 1).length
|
||||||
let successCount = 0
|
let successCount = 0
|
||||||
let failCount = 0
|
let failCount = 0
|
||||||
const error = new Error('error')
|
const error = new Error('error')
|
||||||
@ -2648,13 +2649,31 @@ async function BatchRename () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const promiseList = [] as any[]
|
if (duplicateFilesNum > 0) {
|
||||||
for (let i = 0; i < matchedFiles.length; i++) {
|
ElMessageBox.confirm(`检测到有${duplicateFilesNum}个文件名重复,是否继续?`, '提示', {
|
||||||
promiseList.push(renamefunc(matchedFiles[i]))
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
const promiseList = [] as any[]
|
||||||
|
for (let i = 0; i < matchedFiles.length; i++) {
|
||||||
|
promiseList.push(renamefunc(matchedFiles[i]))
|
||||||
|
}
|
||||||
|
Promise.allSettled(promiseList).then(() => {
|
||||||
|
ElMessage.success(`重命名成功${successCount}个,失败${failCount}个`)
|
||||||
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
ElMessage.info('已取消')
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const promiseList = [] as any[]
|
||||||
|
for (let i = 0; i < matchedFiles.length; i++) {
|
||||||
|
promiseList.push(renamefunc(matchedFiles[i]))
|
||||||
|
}
|
||||||
|
Promise.allSettled(promiseList).then(() => {
|
||||||
|
ElMessage.success(`重命名成功${successCount}个,失败${failCount}个`)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
Promise.allSettled(promiseList).then(() => {
|
|
||||||
ElMessage.success(`重命名成功${successCount}个,失败${failCount}个`)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handelBatchCopyInfo () {
|
function handelBatchCopyInfo () {
|
||||||
|
Loading…
Reference in New Issue
Block a user