[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
楼上的意思是去掉目录层次结构、把所有文件移动同一级目录下?

TOP

先复制再删除不太好,要创建新文件,如果文件很多很大,影响性能。
而本来Windows系统在同一个驱动器之间移动文件几乎没有什么操作,更不用创建新文件(当然不同驱动器之间移动确实是先复制再删除)。
不如用vbs
  1. folderPath = "E:\1"
  2. subfldName = "2"
  3. On Error Resume Next
  4. Set fso = CreateObject("Scripting.FileSystemObject")
  5. fso.MoveFile folderPath & "\" & subfldName & "\*", folderPath & "\"
  6. fso.MoveFolder folderPath & "\" & subfldName & "\*", folderPath & "\"
复制代码

TOP

要使用相对路径把folderPath的值改成"."或其他正确的相对于脚本的路径
  1. folderPath = "E:\123456"
  2. On Error Resume Next
  3. Set fso = CreateObject("Scripting.FileSystemObject")
  4. Set Folders = fso.GetFolder(folderPath).SubFolders
  5. for each oFolder in Folders
  6.     fso.MoveFile oFolder.Path & "\*", folderPath & "\"
  7.     fso.MoveFolder oFolder.Path & "\*", folderPath & "\"
  8.     if 0=oFolder.Files.Count and 0=oFolder.SubFolders.Count then
  9.         oFolder.Delete true
  10.     else
  11.         WScript.Echo oFolder.Path & "中的某些文件(夹)移动失败"
  12.     end if
  13. next
  14. WScript.Echo "Done"
复制代码

TOP

返回列表