1

我有一个包含大量文件的文件夹,我需要创建一些文件夹并将它们放入该文件夹(每个文件夹少于 50 个),文件夹名称可以是任何东西。我认为文件夹名称是数字(1,2,3 .. 等)在这里我做了什么,但不起作用

  Set fso=CreateObject("Scripting.FileSystemObject")
    inputFldr =".\myFolder"
    Set fldr=fso.getFolder(inputFldr)
    dim i
    i=0
    fName = 0

for each file in fldr.files
    i = i+1
    If Not fso.FolderExists(fName) Then fso.CreateFolder(fName)
    fso.MoveFile file, fName

    if i>50 then
        fName = fName + 1
        i = 0
    end if
next
wscript.echo done
4

1 回答 1

3

尝试这个:

Dim i, fName, inputFldr, TmpFdr

Set fso = CreateObject("Scripting.FileSystemObject")
inputFldr = Replace(wscript.scriptfullname,wscript.scriptname,"myFolder")
Set fldr = fso.getFolder(inputFldr)
i = 0
fName = 0
wscript.echo "Input Folder: " & fldr.path
For Each file In fldr.Files
    i = i + 1
    TmpFdr = inputFldr & "\" & fName & "\"
    if Not fso.FolderExists(TmpFdr) Then fso.CreateFolder (TmpFdr)
    file.move TmpFdr

    If i > 50 Then
        fName = fName + 1
        i = 0
    End If
Next
set fldr=nothing
set fso=nothing
于 2013-09-30T02:38:41.117 回答