#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0

    Read from text file, and create extended folder structure


    I need to read a path from a text file then take that data, and create an extended folder structure.

    The issue I have is that I cannot get the extended folder structure created. I can create the last folder, or first folder in the extended structure, but I need to create the whole structure.

    Example: \folder1\folder2\folder3

    I have tried several variations, but my skills with VB Script are only improving. Any help in this endeavor would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0
    Originally Posted by BarrethForlo
    I need to read a path from a text file then take that data, and create an extended folder structure.

    The issue I have is that I cannot get the extended folder structure created. I can create the last folder, or first folder in the extended structure, but I need to create the whole structure.

    Example: \folder1\folder2\folder3

    I have tried several variations, but my skills with VB Script are only improving. Any help in this endeavor would be greatly appreciated.
    I figured it out. It is a bit sloppy, but works..
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    6
    Rep Power
    0
    Const ForReading = 1 ' Defines the constant for the input file we are reading
    '-------------------------------------------------------------------------------------------------------------
    strfile1 = "c:\data\dr\dir-text.txt" ' Name of our input file
    StrText4 = "C:\data\dr\test" ' Location of our ftproot
    StrText5 = "cmd /c mkdir " ' the command that is executed
    '-------------------------------------------------------------------------------------------------------------
    Set fso = CreateObject("Scripting.FileSystemObject") ' Define the system object to be used
    Set objTextFile1 = fso.OpenTextFile (strfile1, ForReading) ' Open the text file for reading (as our input file)
    '-------------------------------------------------------------------------------------------------------------
    Set WshShell = WScript.CreateObject("WScript.Shell") ' Defines the shell script object
    wshShell.CurrentDirectory = StrText4 ' Set the current directory to be what ever is in value StrText4
    '-------------------------------------------------------------------------------------------------------------
    On Error Resume Next ' If an error occurs keep on trucking until end of file
    '-------------------------------------------------------------------------------------------------------------
    Do Until objTextFile1.AtEndOfStream ' Do this part until the list file is fully read
    NewStr2 = objTextFile1.ReadLine ' Tells the script we will be reading the text file 1 line at a Time
    PATH = Chr(34) & StrText4 & NewStr2 & Chr(34) ' Chr(34) adds " to the path to cover spaces in path names
    WshShell.run StrText5 & PATH ' Executes Shell Scripts for each line in the file to create the directories
    wscript.sleep 1000 ' Tells the script to wait 'X' second(s) before looping. Saves on system resources, takes more time.
    Loop ' Loops the code until we reach the end of file
    objTextFile1.Close ' Closes our input file once the script completes
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    4
    Rep Power
    0
    Dim fileReader As String
    fileReader = My.Computer.FileSystem.ReadAllText("C:\test.txt")
    MsgBox(fileReader)

IMN logo majestic logo threadwatch logo seochat tools logo