本帖最后由 pcl_test 于 2015-2-28 18:34 编辑
回复 19# gxx2002
过滤了子文件夹名也包含有file.txt列出的某些字符串导致不符合要求的文件也被复制的问题- @echo off
- setlocal enabledelayedexpansion
- ::设定要搜索的目录
- set "fdir1=原文件夹\"
- ::设定目标文件夹
- set "fdir2=目标文件夹\"
- ::设定修改日期1(yyyymmdd)
- set date1=20150101
- ::设定修改日期2(yyyymmdd)
- set date2=20150228
- ::日期1要早于日期2
- if %date1% geq %date2% echo 日期1要早于日期2,请重新设定 & pause & exit
- if not exist "%fdir2%" md "%fdir2%"
- for /f "delims=" %%a in ('dir /a-d /s /b "%fdir1%"') do >>$1 echo,%%~nxa
- for /f "delims=" %%b in ('type "文件名.txt"') do >>$2 findstr /c:"%%b" $1
- for /f "delims=" %%c in ('type $2') do (
- for /r "%fdir1%" %%e in (.) do (
- set "tdir=%%e"
- if exist "!tdir:~0,-1!%%c" >>$3 echo,!tdir:~0,-1!%%c
- )
- )
- for /f "delims=" %%i in ('type $3') do (
- set "wdate=%%~ti"
- set "wdate=!wdate:~0,4!!wdate:~5,2!!wdate:~8,2!"
- if !wdate! geq %date1% if !wdate! leq %date2% (
- echo "%%i" 最后修改日期为!wdate!
- copy "%%i" "%fdir2%" /y
- )
- )
- del $* /f /q
- pause
复制代码
|