标题: [文件操作] 批处理怎样copy指定时间和文件夹的文件到特定文件夹下(无需拷贝子目录)? [打印本页]
作者: caiyukou 时间: 2012-8-22 16:52 标题: 批处理怎样copy指定时间和文件夹的文件到特定文件夹下(无需拷贝子目录)?
我是新手,请高手指点。谢谢!
目的为了将test文件夹(包含子目录)下的所有特定txt档拷贝到H盘h文件夹下(但子目录不需要拷贝),不考虑文件名相同,找到以下两个脚本,但不知如何合并。见笑了!
代码一:- @echo off
-
- pushd "test" ---D:\test
-
- if not exist "h" md "H:\h"
-
- for /f "tokens=* delims=" %%i in ('dir /s /a-d /b *2.txt') do copy "%%i" "H:\h\%%~nxi"
-
- pause
复制代码
代码二:- @echo off
-
- xcopy /ls /d:1-1-2005 "D:\test" "H:\h" /d:1-1-2005 >tmp1
-
- dir /s /a-d /b>tmp2
-
- for /f "delims=" %%a in ('findstr /l /g:tmp1 tmp2') do (
-
- set "tmp=%%a"
-
- setlocal enabledelayedexpansion
-
- copy /y "%%a" "!tmp:~7!"
-
- endlocal
-
- )
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |