正好之前写了个蛋疼的“根据 id 分组并统计作品数量阈值挑选一张每个艺术家最新的作品”
你改改就能用了
```
#Requires Autohotkey v2.0+
#SingleInstance Force
SrcFolder := "Q:\Doc\Pic\#Pixiv"
DestFolder := "Q:\Doc\Pic\#Pixiv\#Index"
idRegex := "^(\d+)\s+-\s+.+$" ; id as group 1
Threshold := 20
IdList := Map()
Loop Files, SrcFolder . "\*.*", "F"
{
; 处理文件列表
fileName := Trim(A_LoopFileName)
matchArray := {}
match := RegExMatch(fileName, idRegex, &matchArray)
if (match) {
id := matchArray[1]
if (!IdList.Has(id)) {
IdList.Set(id, IdInfo(id, 1, A_LoopFilePath))
} else {
IdList.Get(id).count += 1
IdList.Get(id).latestFile := A_LoopFilePath
IdList.Get(id).latestFileName := fileName
}
}
}
; 阈值过滤
IdListPicked := Map()
for id, info in IdList
{
if (info.count >= Threshold)
{
IdListPicked.Set(id, info)
}
}
; 移动
debug_pickArtStr := "" ;debug
if (IdListPicked.Count > 0){
try FileDelete(DestFolder . "\*.*")
try DirCreate(DestFolder)
for id, info in IdListPicked
{
if(FileExist(info.latestFile)) {
FileCopy(info.latestFile, DestFolder)
; debug_pickArtStr .= info.count . ": " . info.latestFileName . "`n" ;debug
}
}
}
; 输出到文件
; 输出处理完成的消息
MsgBox("文件处理完成`n`n"
"作品数量阈值" . Threshold . "`n 共" . IdListPicked.Count . "艺术家符合"
)
; MsgBox(debug_pickArtStr) ;debug
Class IdInfo {
id := 0
count := 0
latestFile := ""
__New(id:=0, count:=0, latestFile:="", latestFileName:="") {
this.id := id
this.count := count
this.latestFile := latestFile
this.latestFileName := latestFileName
}
}
ExitApp
```