Follow us on Twitter
Create Folders from a list in an .xls Spreadsheet PDF Print E-mail
Advertisements
I needed to create over 300 folders with specific file names.
These names were listed in an excel doc and I didn't want to create the folders by hand.
This script will create folders based on the listed text in an excel file.

----------COPY EVERYTHING BELOW THIS LINE for the Script----------
'This script will create folders based on the listed text in an excel file.
' Created by Chey Harden 7.6.07

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\Test.xls") 'put the path to the .xls file here
objExcel.Visible = False

i = 1

Do Until objExcel.Cells(i, 1).Value = "" ' first value is row (i), second value is the column (1)
   
    strNewFolderName = objExcel.Cells(i, 1).Value
   
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objFolder = objFSO.CreateFolder("C:\scripts\" & strNewFolderName) 'Location to create the folders

    i = i + 1
Loop

 

 

----------COPY EVERYTHING ABOVE THIS LINE for the Script----------

 

PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!

To make this script work you will need the items below!


1. Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\Test.xls") 'put the path to the .xls file here
2. Do Until objExcel.Cells(i, 1).Value = "" ' first value is row (i), second value is the column (1)
3. Set objFolder = objFSO.CreateFolder("C:\scripts\" & strNewFolderName) 'Location to create the folders


This information is provided "AS IS" with no warranties expressed or implied.


Advertisements