Jump to content

Create Folder Tree from reading in txt file


SimJ
 Share

Recommended Posts

Hello all, I'm relatively new to AutoIt and NOT a developer... Normally I can stumble my way through something I'm trying to figure out, but I dont have the luxury of time on this project.

I'm wondering if anyone could help me with code to read in a txt file containing some structure... The file looks something like the example below:

1.1

Document

1.1.1

Document child folder

1.1.1.1

Document Grandchild folder

1.1.1.1

Document-1111.PDF

1.2

Document

1.2.1

Document child folder

1.2.1.1

Document Grandchild folder

1.2.1.1

Document-1211.PDF

... The task i'd like to accomplish is to read in the initial volume number(1.1) then suffix the text on the following line(Document) and turn that into a folder name and create the folder on my hard drive. So, the name for the first folder would be "1.1 Document". Then recognize if there is a child item for that folder, and, if there is, make another folder following the same guildlines... soo.. with the txt file above, in the end i'd like to create a folder tree like what is shown below:

+1.1 Document

++1.1.1 Document Child Folder

+++1.1.1.1 Document Grandchild Folder

+++Document-1111.PDF

+1.2 Document

++1.2.1 Document Child Folder

+++1.2.1.1 Document Grandchild Folder

+++Document-1211.PDF

Any *Bored* **Genius** Developers willing to give this a shot? I'll be working on it also...but, I know there are more skilled and efficient autoit developers out there that may be willing to help and could do it MUCH more quickly than I could.

Anyone willing to take on the challenge, I'd GREATLY appreciate it!

If I dont get any responses to this, I'll post my code once I finally get it figured out.

In the mean time, if anyone is interested in code that will parse through an HTML file and pull out certain values, let me know, and i'd be happy to paste it.

Thanks all! :)

SimJ

Link to comment
Share on other sites

Look at Auto3Lib from PaulIA.

There are TreeView functions/examples - also with helpfile included.

Also use forum Seach engine - this was discused already.

Thank you for the reply and the link to the additional functions. I'm sure I will be able to use them in the future...

However, I'm not trying to build a GUI treeview from the txt file. I'd like to build a an actual tree in the filesystem. Meaning I want to create a bunch of directories in my filesystem based on what is read in from the txt file.

Thanks!

SimJ

Link to comment
Share on other sites

Thank you for the reply and the link to the additional functions. I'm sure I will be able to use them in the future...

However, I'm not trying to build a GUI treeview from the txt file. I'd like to build a an actual tree in the filesystem. Meaning I want to create a bunch of directories in my filesystem based on what is read in from the txt file.

Thanks!

SimJ

Oh sorry then.

You can prepare whole path from TXT first and then use DirCreate() with that whole path:

DirCreate("C:\Test1\Folder1\Folder2")

Link to comment
Share on other sites

The Code Below works for what was mentioned above:

$file = FileOpen("test.txt", 0)
$file1 = FileOpen("Test1.txt", 1)

Do
    $tst = FileReadline($file)
    $num1 = StringLeft($tst,2)
    $num = StringIsFloat($num1)
    If $tst <> "" Then
        If $num == 1 Then
            FileWrite($file1, $tst &" ")
        Else 
            FileWrite($file1, $tst & "\")
        EndIf
    EndIf
Until $tst = ""

FileClose($file1)

$file1 = FileOpen("test1.txt", 0)
$tst1 = FileReadline($file1)
DirCreate("c:\" & $tst1)

FileClose($file)
FileClose($file1)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...