VB Script for creating multiple folders and saving multiple text files in it.

For VB script to run all you need to do is open a text file , copy paste the below contents and save it with .vbs extension.

You need to change the working directory value in the work_dir variable and then you can use it for data generation purpose.

————————————————————————————-

option explicit
Dim Stuff, myFSO, WriteStuff, dateStamp, fname,work_dir, objFolder,slash,folder_name
dateStamp = Date()
slash = “\”

Stuff = “1234567890 ABCDEFGHIJKLMOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz”
work_dir = “C:\Users\User-3\Desktop\Kedar\VB script\test\”
Set myFSO = CreateObject(“Scripting.FileSystemObject”)
for folder_name = 1 to 2
set objFolder = myFSO.CreateFolder (work_dir & slash & folder_name)

for fname = 101 to 500
Set WriteStuff = myFSO.OpenTextFile(work_dir & slash & folder_name & slash & fname & “.txt”, 2, True)
WriteStuff.WriteLine(Stuff)
next
next
WriteStuff.Close
SET WriteStuff = NOTHING
SET myFSO = NOTHING

——————————-

Advertisements

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: