我也来一个- @echo off
- set "P=%~p0"
- set "P=%P:\=\\%"
- set "wmic=wmic datafile where"
- for /f "tokens=1*" %%a in ('%wmic% "drive='%~d0' and path='%P%' and extension='jpg'" get LastModified^,name^|find "\"') do (
- set "d=%%a"
- for /f "tokens=*" %%c in ("%%b") do set "File=%%~nxc"
- setlocal enabledelayedexpansion
- set "d=!d:~,4!-!d:~4,2!-!d:~6,2!-!d:~8,6!"
- ren "!File!" "!d!.jpg"
- endlocal
- )
- pause
复制代码 vbs 权当练习:- set fso = createobject("scripting.filesystemobject")
- for each file in fso.getfolder(".").files
- ext = fso.getextensionname(file)
- if lcase(ext) = "jpg" then
- d = file.datelastmodified
- d = right(year(d),4)&"-"&right("0"&month(d),2)&"-"&_
- right("0"&day(d),2)&"-"&right("0"&hour(d),2)&_
- right("0"&minute(d),2)&right("0"&second(d),2)
- if lcase(file.name) <> d & ".jpg" then file.name = d & ".jpg"
- end if
- next
- msgbox "OK"
复制代码
|