Sign in to follow this  
Followers 0
jeantje

Create files/folders from list

4 posts in this topic

Hi guys i have a little problem, I need to create an exact file / folders structure with empty files from this list.

De volumenaam van station C is OS
 Het volumenummer is BA4B-049E

 Map van C:\

03-02-2010  14:30    <DIR>          dell
24-12-2009  21:46    <DIR>          Drivers
31-01-2010  01:18    <DIR>          Intel
02-12-2006  06:37           904.704 msdia80.dll
14-07-2009  04:20    <DIR>          PerfLogs
25-02-2010  12:55    <DIR>          Program Files
25-02-2010  12:57    <DIR>          Program Files (x86)
24-02-2010  11:35    <DIR>          Temp1234
05-02-2010  13:04    <DIR>          Users
24-02-2010  11:07    <DIR>          Windows
               1 bestand(en)          904.704 bytes

 Map van C:\dell

03-02-2010  14:30    <DIR>          .
03-02-2010  14:30    <DIR>          ..
31-01-2010  02:54    <DIR>          CAE
31-01-2010  03:53               416 DBRM.ini
31-01-2010  01:25                66 dell.cae
31-01-2010  02:54    <DIR>          DownloadStore
31-01-2010  02:54            29.936 dscstart64.exe
               3 bestand(en)           30.418 bytes

Any idea's I have not.

I tried it with StringRegExp, but no succes


Share this post


Link to post
Share on other sites



Maybe it is easier when you use 'dir /w' to create the list.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

jeantje,

This should do what you want:

#include <Array.au3>
#include <File.au3>

Global $aList

_FileReadToArray("Dir.txt", $aList)

For $i = 1 To $aList[0]

    $sLine = $aList[$i]

    $iIndex = StringInStr($sLine, "Map van")
    If $iIndex <> 0 Then
        $sPath = StringMid($sLine, $iIndex + 8)
        If StringRight($sPath, 1) <> "\" Then $sPath &= "\"
        $i = _Level($i + 2)
    EndIf

Next

Func _Level($iStart)

    For $j = $iStart To $aList[0]

        $sLine = $aList[$j]

        If StringLeft($sLine, 1) = " " Then ExitLoop

        $sName = StringMid($sLine, 37)

        If StringinStr($sLine, "<DIR>") <> 0 Then
            Switch $sName
                Case ".", ".."
                    ; Ignore
                Case Else
                    ;ConsoleWrite("Folder: " & $sPath & $sName & @CRLF)
                    DirCreate($sPath & $sName)
            EndSwitch
        Else
            ;ConsoleWrite("File:   " & $sPath & $sName & @CRLF)
            FileWrite($sPath & $sName, "")
        EndIf

    Next

    Return $j

EndFunc

I put your data into a file and then read it into an array - you may wish to do it another way. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank you now I can revive the files on my dead hdd


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