[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文件操作] 批处理怎样根据复制文件清单在指定盘符下复制文件到指定文件夹?

本帖最后由 zhoubin 于 2011-10-2 21:11 编辑

问题描述:
根据复制清单1.txt在X:盘根目录及各级子目录(含隐藏文件及隐藏文件夹)下查找复制清单1中的文件复制到C:\IE8-CHS文件夹下
根据复制清单2.txt在X:盘根目录及各级子目录(含隐藏文件及隐藏文件夹)下查找复制清单2中的文件复制到C:\IE8-CHS\support文件夹下
根据复制清单3.txt在X:盘根目录及各级子目录(含隐藏文件及隐藏文件夹)下查找复制清单3中的文件复制到C:\IE8-CHS\update文件夹下
谢谢大家,祝各位老大国庆节快乐!!!

如果不考虑以下可能很容易,虽然我不会: 清单中文件是否包含读写锁定及畸形路径,无权限读的文件,是否需要保持文件名不变(其实这一点就很难达到,比如一个文件叫1.一般根本没法创建的)

TOP

复制清单中的内容是什么?(复制上来看看)

文件名,还是文件完全路径?

TOP

手机上网, 资料不在身边
复制文件列表是TxT文档,里面没有路径
谢谢了

TOP

本帖最后由 zhoubin 于 2011-10-3 10:55 编辑

回复 3# Hello123World


    复制清单1.txt
  1. xpshims.dll
  2. wups2.dll
  3. wuaueng.dll
  4. wininet.dll.mui
  5. wininet.dll
  6. winfxdocobj.exe.mui
  7. winfxdocobj.exe
  8. webcheck.ini
  9. webcheck.dll.mui
  10. webcheck.dll
  11. vgx.dll
  12. vbscript.dll.mui
  13. vbscript.dll
  14. urlmon.dll.mui
  15. urlmon.dll
  16. url.dll
  17. ticrf.rat
  18. tdc.ocx
  19. sqmapi.dll
  20. spupdsvc.exe
  21. spuninst.exe
  22. spmsg.dll
  23. ShowMenu.reg
  24. shlwapi.dll
  25. shdocvw.dll
  26. SetupIE8.CMD
  27. popupblk.wav
  28. pngfilt.dll
  29. pdm.dll
  30. occache.ini
  31. occache.dll.mui
  32. occache.dll
  33. navstart.wav
  34. mstime.dll
  35. msrating.dll.mui
  36. msrating.dll
  37. msoert2.dll
  38. msls31.dll
  39. mshtmler.dll.mui
  40. mshtmler.dll
  41. mshtmled.dll
  42. mshtml.tlb
  43. mshtml.dll.mui
  44. mshtml.dll
  45. mshta.exe.mui
  46. mshta.exe
  47. msfeedssync.exe
  48. msfeedsbs.mof
  49. msfeedsbs.dll.mui
  50. msfeedsbs.dll
  51. msfeeds.mof
  52. msfeeds.dll
  53. msdbg2.dll
  54. mlang.dll
  55. licmgr10.dll.mui
  56. licmgr10.dll
  57. jsproxy.dll
  58. jsprofilerui.dll.mui
  59. jsprofilerui.dll
  60. jsprofilercore.dll.mui
  61. jsprofilercore.dll
  62. jsdebuggeride.dll.mui
  63. jsdebuggeride.dll
  64. jsdbgui.dll.mui
  65. jsdbgui.dll
  66. jscript.dll.mui
  67. jscript.dll
  68. Internet Explorer3.reg
  69. Internet Explorer2.reg
  70. Internet Explorer1.REG
  71. install.ins
  72. inseng.dll.mui
  73. inseng.dll
  74. infobar.wav
  75. inetset.iem
  76. inetres.dll
  77. inetres.adm
  78. inetcpl.cpl.mui
  79. inetcpl.cpl
  80. inetcorp.iem
  81. inetcomm.dll
  82. imgutil.dll
  83. iexplore.exe.mui
  84. IEXPLORE.EXE.local
  85. iexplore.exe
  86. iexplore.chm
  87. ieuinit.inf
  88. ieui.dll.mui
  89. ieui.dll
  90. ieudinit.exe.mui
  91. ieudinit.exe
  92. iesupp.chm
  93. iesetup.dll.mui
  94. iesetup.dll
  95. iertutil.dll.mui
  96. iertutil.dll
  97. iernonce.dll.mui
  98. iernonce.dll
  99. ieproxy.dll
  100. iepeers.dll.mui
  101. iepeers.dll
  102. ieframe.dll.mui
  103. ieframe.dll
  104. ieeula.chm
  105. iedvtool.dll.mui
  106. iedvtool.dll
  107. iedkcs32.dll.mui
  108. iedkcs32.dll
  109. iecompat.dll
  110. ieapfltr.dll
  111. ieapfltr.dat
  112. ieakui.dll.mui
  113. ieakui.dll
  114. ieaksie.dll.mui
  115. ieaksie.dll
  116. ieakmmc.chm
  117. ieakeng.dll.mui
  118. ieakeng.dll
  119. ie8props.propdesc
  120. ie8.reg
  121. ie4uinit.exe.mui
  122. ie4uinit.exe
  123. icrav03.rat
  124. icardie.dll.mui
  125. icardie.dll
  126. html.iec.mui
  127. html.iec
  128. hmmapi.dll.mui
  129. hmmapi.dll
  130. FlashPlayer.cmd
  131. feeddisc.wav
  132. extexport.exe
  133. dxtrans.dll
  134. dxtmsft.dll
  135. corpol.dll
  136. CLSID.reg
  137. browseui.dll
  138. advpack.dll.mui
  139. advpack.dll
  140. admparse.dll.mui
  141. admparse.dll
复制代码
复制清单2.txt
  1. xmllite.dll
  2. normnfkd.nls
  3. normnfkc.nls
  4. normnfd.nls
  5. normnfc.nls
  6. normidna.nls
  7. normaliz.dll
  8. nlsdl.dll
  9. idndl.dll
复制代码
复制清单3.txt
  1. updspapi.dll
  2. update.ver
  3. update.inf
  4. update.exe.manifest
  5. update.exe
  6. sqmapi.dll
  7. iesetup.exe
  8. iecustom.dll
  9. ie8.cat
  10. eula.rtf
复制代码
实际上是根据这三个复制清单.txt遍历X:盘(w i n 7 p e 系统盘 ),查找到相应的文件,并把找到的文件复制到指定的三个文件夹内,这里面有可能还会找到同名文件呢,不过,这不要紧,关键是这个批处理我不会写。
一楼的求助帖,之所以写成是在D:盘中查找,是为了便于各位理解,因为一般的电脑是没有X:盘的。。。。

TOP

唉,看样子,这个真的很难。。。。

TOP

"看样子,这个真的很难。。。。"

  高手们有的是,不知不愿或是不屑???

TOP

本帖最后由 lvsehuaxue 于 2012-2-12 21:50 编辑
  1. @echo off
  2. for /f "skip=1" %%i in ('^(wmic logicaldisk where drivetype^='3' get name^)') do (
  3.   echo %%i|findstr ":">nul&&(
  4.     for %%j in (1.txt 2.txt 3.txt) do (
  5.       for /f "delims=" %%a in (%%j) do (
  6.         for /f "delims=" %%b in ('dir /a /b /s "%%i\%%a"') do (
  7.           for /f "tokens=1-3" %%i in ('attrib "%%b"') do (
  8.             echo %%i|findstr /i "\<s\> \<h\> \<sh\>">nul&&(attrib -s -h "%%b"&set abc==)
  9.             echo %%j|findstr /i "\<s\> \<h\> \<sh\>">nul&&(attrib -s -h "%%b"&set abc==)
  10.             echo %%k|findstr /i "\<s\> \<h\> \<sh\>">nul&&(attrib -s -h "%%b"&set abc==)
  11.           )
  12.           if %%j equ 1.txt copy "%%b" C:\IE8-CHS文\
  13.           if %%j equ 2.txt copy "%%b" C:\IE8-CHS\support\
  14.           if %%j equ 3.txt copy "%%b" C:\IE8-CHS\update\
  15.           if defined abc (attrib +s +h "%%b"&set abc=)
  16.         )
  17.       )
  18.     )
  19.   )
  20. )
  21. pause
复制代码

TOP

回复 8# lvsehuaxue


    for /f "skip=1" %%i in ('^(wmic logicaldisk where drivetype^='3' get name^)')改为for  %%i in  (c d e f g h i j k )用不了,还要修改哪里,请指教下,谢谢

TOP

返回列表