Jump to content

Find subdirectories?


Recommended Posts

This may help you.

#include <Array.au3>

;An array of sub-directories not to be backed up this time.
Local $aPrevBkUp[2] = ["C:\Program Files\AutoIt3\Examples\GUI", _
        "C:\Program Files\AutoIt3\Examples\GUI\Advanced"]

;List of all sub-directories
Local $sSortedDir = StringStripWS(_GetDOSOutput('dir "C:\Program Files\AutoIt3\" /A:-A /S /B /O:N'), 3)
;ConsoleWrite(_GetDOSOutput('dir /?') & @CRLF) ; Dir help
ConsoleWrite($sSortedDir & @CRLF)

;Remove sub-directories not requiring backup
For $i = 0 To UBound($aPrevBkUp) - 1
    If StringInStr($sSortedDir, $aPrevBkUp[$i]) <> 0 Then $sSortedDir = StringReplace($sSortedDir, $aPrevBkUp[$i] & @CRLF, "")
Next

;Change string of sub-directories into an array of sub-directories.
Local $aNewBkUpDirs = StringSplit($sSortedDir, @CRLF, 3)

_ArrayDisplay($aNewBkUpDirs)




; http://www.autoitscript.com/forum/index.php?showtopic=108678&view=findpost&p=765520
; http://www.autoitscript.com/forum/index.php?showtopic=106254&view=findpost&p=750640
Func _GetDOSOutput($command)
    Local $text = '', $Pid = Run('"' & @ComSpec & '" /c ' & $command, '', @SW_HIDE, 2 + 4)
    While 1
        $text &= StdoutRead($Pid, False, False)
        If @error Then ExitLoop
        Sleep(10)
    WEnd
    Return $text
EndFunc ;==>_GetDOSOutput
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...