有大量包含图片的文件夹,如何批量选中每个文件夹中的第一张图片

190 天前
 stx0821

选中之后复制出来做为预览图片,在 windows 系统下,有这种操作吗

765 次点击
所在节点    Windows
5 条回复
proxytoworld
190 天前
只能用脚本吧
lisxour
190 天前
资源管理器没有这种操作,只有代码才能实现
tool2d
190 天前
问了一下 gpt: "写一个 bat, 遍历目录,列出每个目录下的第一个图片文件。"

直接帮我了写一个。
franswish
190 天前
如何定义“第一个”?首字母排序?创建时间排序?
byzod
188 天前
正好之前写了个蛋疼的“根据 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

```

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/991349

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX