1.

Solve : Split folders??

Answer»

Hey there,

I have a folder with over 4000+ files, and I'd LIKE to split that folder in other folders with each 100 files. So there should be 40 new folders with each 100 files of the main big folder (the one with 4000+ files). I have no idea how to do this, I THOUGHT about something like echo the 'DIR' command into a textfile, and then with 'FOR' command read out of the textfile all the names but then I'm stuck. Can ANYONE please help me creating such code?echo off
mkdir 1 |mkdir 2 |mkdir 3 |mkdir4 |mkdir 5 |mkdir 6 |mkdir 7 |mkdir 8 |mkdir 9 |Mkdir 10
mkdir 11 |mkdir 12 |mkdir 13 |mkdir 14 |mkdir 15 |mkdir 16 |mkdir 17 |mkdir 18 |mkdir 19 |Mkdir 20
mkdir 21 |mkdir 22 |mkdir 23 |mkdir 24 |mkdir 25 |mkdir 26 |mkdir 27 |mkdir 28 |mkdir 29 |Mkdir 30
mkdir 31 |mkdir 32 |mkdir 33 |mkdir 34 |mkdir 35 |mkdir 36 |mkdir 37 |mkdir 38 |mkdir 39 |Mkdir 40
:0aaa
set c=0
set /a d=%d%+1
for /F "tokens=1 delims=*" %%a in ('dir /a * /b') do ( 
  move %%a %d%
  set /a c=%%c%%+1
  if "%c%"=="100" Goto 0aaa
  )

i don thave time to test this, it might work . put it in a batch file inside the directory it only creates two folders with just nothing in it... hmmm weird. I'll try to debug it myself first.

Edit: I have no idea how to make this work, I don't get what's wrong 'cause the code seems good to mevbscript
Code: [Select]On Error Resume NEXT
Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test\test"
Set objFolder = objFS.GetFolder(strFolder)
iCounter=0
dirCounter=1
If Not objFS.FolderExists(dirCounter) Then
objFS.CreateFolder(CStr(dirCounter))
End If
For Each strFiles In objFolder.Files
If strFiles.Name <> "moveFiles4000.vbs" Then
WScript.Echo "Moving " & strFiles.Name
objFS.MoveFile strFiles.Name,dirCounter & "\" & strFiles.Name
iCounter=iCounter+1
If iCounter = 100 Then
    dirCounter=dirCounter+1
    objFS.CreateFolder(CStr(dirCounter))
iCounter=0
End If

End If
Next
diablo416, did you even try that code?



Discussion

No Comment Found