Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Folders From Text File and add Sub Folders

Status
Not open for further replies.

Nu2Java

Technical User
Jun 5, 2012
166
US
Hello,

I am creating folders in a directory from a list of part numbers in a text file. Right now I am using a batch file that is run within each folder created manually, but is not very efficient. I have not gotten in to multiple directories and subdirectory creation. Here is what I am trying to do ...

Code for reading the text file with part numbers I want to create folders for:
Code:
dim objFileSys, objReadFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFileSys.OpenTextFile("C:\Folders\FolderFile.txt", ForReading)

Do until objReadFile.AtEndOfStream = True
    objFileSys.CreateFolder(objReadFile.ReadLine)

Loop
objReadFile.Close
Set objReadFile = Nothing
Set objFileSys = Nothing

But inside of each of those folders, I want to create sub-folders:
Code:
PROCESS-1
PROCESS-2
PROCESS-3
PROCESS-4

Any help is greatly appreciated
 
A starting point:
Code:
...
Do Until objReadFile.AtEndOfStream = True
    strFolder = objReadFile.ReadLine
    objFileSys.CreateFolder strFolder
    For i = 1 To 4
       objFileSys.CreateFolder strFolder & "\PROCESS-" & i
    Next
Loop
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV .... This is just what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top