返回列表 发帖
楼上的意思是去掉目录层次结构、把所有文件移动同一级目录下?

TOP

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

TOP

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

TOP

返回列表