Sign in to follow this  
Followers 0
SimJ

Building a Directory structure based off of txt in a file

2 posts in this topic

Hello all..

I'm having a bit of trouble with the logic for this one.... And was wondering if anyone could help.

I have the txt below in a file:

1

Title Folder

1.1

Folder

1.1

File.txt

1.1.1

Folder Child

1.1.1

file.txt

1.1.1.1

Folder GrandChild

1.2

Folder

1.2

file.txt

1.2.1

Folder Child

1.2.2.1

Folder GrandChild

1.2.2.1

file.txt

I would like to use that txt file to read in line by line and build a directory structure that looks like:

Posted Image

I manually created the above example... I'm trying to create a script that will make that structure by reading in data from a file, line by line.

Any help is GREATLY appreciated! :)

SimJ

Share this post


Link to post
Share on other sites



Here is one way to do this with some stipulations:

#include 
#include 

Dim $aRecords
If Not _FileReadToArray("file.txt",$aRecords) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf


For $X = 1 to $aRecords[0] - 1
        $PATH = StringReplace($aRecords[$X], ".", "\")
        DirCreate ( @ScriptDir & "\" & $PATH)
Next

Your text file structure would have to look like this to retain the folder names:

1 Title Folder

1 Title Folder.1 Folder

1 Title Folder.1 Folder.1 Folder Child

1 Title Folder.1 Folder.1 Folder Child.1 Folder GrandChild

1 Title Folder.2 Folder

1 Title Folder.2 Folder.1 Folder Child

1 Title Folder.2 Folder.2 Folder Child

1 Title Folder.2 Folder.2 Folder Child.1 Folder GrandChild

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0