- 新增文件扫描逻辑,遍历目录下所有文件并记录路径与元信息 - 新增核心处理逻辑,识别.HEIC图片及其对应的.MOV实况视频 - 自动将匹配的实况视频移动至 duplicates 目录以供用户确认删除 - 添加构建脚本build.sh用于编译和压缩可执行文件 - 更新.gitignore忽略.idea目录 - 重写README.md,明确工具用途、需求及效果预览 - 初始化模块依赖管理(go.mod, go.sum)及相关工具类和变量定义
42 lines
966 B
Go
42 lines
966 B
Go
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"kenaito-media-group-tool/util"
|
|
"kenaito-media-group-tool/vars"
|
|
"log"
|
|
"os"
|
|
"path"
|
|
"path/filepath"
|
|
)
|
|
|
|
type FileScanner struct {
|
|
}
|
|
|
|
func (FileScanner) DoScan(rootDir string) {
|
|
fmt.Printf("=== 开始扫描文件 \n")
|
|
if err := filepath.Walk(rootDir, visitFile); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// 定义walkFn回调函数visit
|
|
func visitFile(currentPath string, info os.FileInfo, err error) error {
|
|
if err != nil {
|
|
return err // 如果有错误,直接返回
|
|
}
|
|
if !info.IsDir() {
|
|
ext := path.Ext(currentPath)
|
|
if ".exe" != ext {
|
|
vars.GlobalFilePathList = append(vars.GlobalFilePathList, currentPath)
|
|
// filename, include ext
|
|
vars.GlobalFilePath2FileNameExtMap[currentPath] = filepath.Base(currentPath)
|
|
// filename, exclude ext
|
|
vars.GlobalFilePath2FileNameMap[currentPath] = util.GetFileNameWithoutExt(currentPath)
|
|
// file ext
|
|
vars.GlobalFilePath2FileExtMap[currentPath] = ext
|
|
}
|
|
}
|
|
return nil
|
|
}
|