本帖最后由 apang 于 2015-2-2 18:21 编辑
- @echo off
- set "srcDir=D:\Test"
-
- call :Lp "%srcDir%\"
- pause & exit/b
-
- :Lp
- set "p=%~p1"
- set "w=wmic DataFile where "Drive='%~d1' and Path='%p:\=\\%'" get CreationDate^,Name"
- for /f "tokens=1*" %%a in ('%w% 2^>nul^|findstr /b [0-9]') do (
- set "D=%%a"
- for /f "delims=" %%c in ("%%b") do (
- set "file=%%~fc"
- set "Name=%%~nc"
- setlocal enabledelayedexpansion
- echo,ren "!file!" "!Name!_!D:~,4!-!D:~4,2!-!D:~6,2!%%~xc"
- endlocal
- )
- )
- for /d %%a in ("%~1*") do call :Lp "%%a\"
复制代码
|