本帖最后由 ppll2030 于 2024-9-19 22:27 编辑
没有cr2文件,就用jpg和jpeg来测试,测试通过。只要文件有exif信息并有拍摄时间,就可以获取并比对。
脚本保存为bat,跟jpg文件放一块,运行即可把同名且拍摄时间一致的cr2文件复制过来。
需匹配的文件夹cr2-1、cr2-2均在jpg文件夹外。如路径不对,请自行修改第6行。- @echo off &setlocal enabledelayedexpansion
- >temp.vbs echo Set objFSO = CreateObject("Scripting.FileSystemObject"):Set objFile = objFSO.GetFile(WScript.Arguments(0)):Set shell = CreateObject("Shell.Application"):Set folderitem = shell.Namespace(objFile.ParentFolder.Path).ParseName(objFile.Name):WScript.Echo folderitem.ExtendedProperty("System.Photo.DateTaken")
-
- for /f "delims=" %%i in ('dir /b /a-d *.jpg') do (
- for /f "delims=" %%x in ('cscript //nologo temp.vbs "%%i"') do set a=%%x
- for /f "delims=" %%f in ('dir /b /s /a-d "..\CR2-1\%%~ni.cr2" "..\CR2-2\%%~ni.cr2"') do (
- for /f "delims=" %%x in ('cscript //nologo temp.vbs "%%f"') do set b=%%x
- if "!a!" == "!b!" (copy %%f "%%~dpi" /y)
- )
- )
- del temp.vbs&pause
复制代码 想到一个个获取时间对于大量图片可能速度有点慢,再弄一个提提速度
先获取所有图片的时间到临时文件,再挨个匹配,理论上应该可以省很多时间。欢迎楼主测试。- @echo off &setlocal enabledelayedexpansion
- >temp.vbs echo Set objFSO = CreateObject("Scripting.FileSystemObject"):Path = WScript.Arguments(0):Set Text = objFSO.CreateTextFile(WScript.Arguments(1)):Set Shell = CreateObject("Shell.Application"):Set objPath = Shell.NameSpace(Path):For Each File In objFSO.GetFolder(Path).Files:If LCase(Right(File.Name,4))=".jpg" Or LCase(Right(File.Name,4))=".cr2" Then:Set objFile = objPath.ParseName(File.Name):strDateTaken = objFile.ExtendedProperty("System.Photo.DateTaken"):Text.WriteLine File.Name ^& ":" ^& strDateTaken:End If:Next:Text.Close
-
- cd..
- set "pd=%cd%"
- cd %~dp0
- cscript //nologo temp.vbs "%cd%" "$.txt"
- cscript //nologo temp.vbs "%pd%\CR2-1" "$1.txt"
- cscript //nologo temp.vbs "%pd%\CR2-2" "$2.txt"
-
- for /f "tokens=1*delims=:" %%a in ($.txt) do (
- for /f "tokens=1*delims=:" %%x in ('type $1.txt^|findstr /ic:"%%~na"') do (
- if "%%b" == "%%y" copy "%pd%\CR2-1\%%x" %~dp0 /y)
- for /f "tokens=1*delims=:" %%x in ('type $2.txt^|findstr /ic:"%%~na"') do (
- if "%%b" == "%%y" copy "%pd%\CR2-2\%%x" %~dp0 /y)
- )
- del $*.txt temp.vbs&pause
复制代码
|