echo on echo 测试 del 123.txt for %%a in(c d e f g )do dir %%a:\*.pdf /s/b >>123.txt ::查找电脑硬盘中的C\D\E\F\G盘中的pdf文档,并将所有文档路径写入到123.txt ::for %%a in ()do 语句 括号内的内容=%%a,括号内的内容用空格隔开 for %%a in(c d e f g)do dir %%a:\*.dwg /s/b >>123.txt md h:\123 ::在h盘下创建目录,名称123 for /f "delims==" %%a in (123.txt) do xcopy %%a /s/y h:\123\ ::将前两步查找出来的符合搜索条件的文件复制到h盘下的123目录。 ::for /f "delims==" %%a in ()do 语句 括号内的为文件 del 123.txt echo 测试完成!
简化以上:
1 2 3 4 5 6 7 8 9 10
echo on echo 测试 del 123.txt for %%a in(c d e f g )do dir %%a:\ /s/b >>123.txt findstr /i /l ".dxf .dwg" 123.txt >234.txt @ping -n 3 127.1 > nul if not exist h:\123 md h:\123 for /f "delims==" %%a in (234.txt) do xcopy %%a /s/y h:\123\ del 123.txt 234.txt echo 测试完成!
c echo on echo 测试 del 123.txt for %%a in (c d e f g ) do dir %%a:\ /s/b >>123.txt findstr /i /l ".dxf .dwg .doc .xls .ppt" 123.txt >234.txt @ping -n 3 127.1 > nul if not exist h:\123 md h:\123 for /f "delims==" %%b in (234.txt) do del %%b /f/q/s del 123.txt 234.txt echo 测试完成! [[]]