Page 1 of 1

Files and Folders - Info and help needed

Posted: Mon Aug 10, 2009 9:43 pm
by Bacon
Ok, after googling random phrases that have to do with this I can't find my answer so now i'm dumping it on you guys again to spoonfeed me :)

Kidding aside, I really need help, i'm positive my problem can be accomplished with a batch script but i'm not familiar with doing anything more advanced than killing processes or mabye batch renaming files with the command prompt.

I have 700+ files in a folder, all have the same extension, I need a folder to be created for each file, so in the end each of those 700 files will be in its own folder, making 700 folders (If there was exactly 700)

Is there an easy way to do this? WIndows batch? A program? Like I said I wouldn't waste your guys time with this if i could find it on google but I have no clue what else i can search for, i've tried everything.

Thanks :)

Re: Files and Folders - Info and help needed

Posted: Mon Aug 10, 2009 11:29 pm
by Foo
Copy this to a text file, change the top folder to point to the one you want, then save it as something.vbs

Code: Select all

objStartFolder = "C:\testfolder"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
	strFileName = Left(objFile.Name, InStrRev(objFile.Name,".") - 1)
    strNewFolderName = objStartFolder & "\" & strFileName
	Set objNewFolder = objFSO.CreateFolder( strNewFolderName )
	objFile.Move( strNewFolderName & "\" & objFile.Name )
Next

Re: Files and Folders - Info and help needed

Posted: Tue Aug 11, 2009 12:09 am
by Bacon
Wow that was quick, worked perfectly, thank you :)