回复 11# gxx2002
批处理跟file.txt放在一起运行- @echo off
- setlocal enabledelayedexpansion
- ::设定要搜索的目录
- set "fdir1=D:\test\"
- ::设定目标文件夹
- set "fdir2=D:\new\"
- ::设定修改日期1(yyyymmdd)
- set date1=20150102
- ::设定修改日期2(yyyymmdd)
- set date2=20150225
- ::日期1要早于日期2
- if %date1% geq %date2% echo 日期1要早于日期2,请重新设定 & pause & exit
- for /f "delims=" %%a in ('type "file.txt"') do (
- if not exist "%fdir2%%%a\" md "%fdir2%%%a\"
- for /f "delims=" %%b in ('dir /a-d /s /b "%fdir1%" ^|findstr /c:"%%a"') do (
- for /f "tokens=1*" %%c in ('dir /tw "%%b" ^|findstr ":"') do (
- set "wdate=%%c"
- set "wdate=!wdate:~0,4!!wdate:~5,2!!wdate:~8,2!"
- if !wdate! geq %date1% if !wdate! leq %date2% (
- echo "%%b"
- copy "%%b" "%fdir2%%%a\" /y)
- )
- )
- )
- pause
复制代码
|