Sign in to follow this  
Followers 0
drx

Another Small script question

20 posts in this topic

After noon everyone. Another script baffeling me..... All code looks ok, added abit to the last msg box so i would know what the variables return to make sure they look ok....Attempting to delete the temp files from remote computers on a need to basis....

Script runs fine, msg pops up at the end and variables look ok, but when i look at the folders, nothing at all is being deleted....what is holding it up? (Also, i have domain admin rights, no permission issues...)

Dim $user,$path,$pcname,$path1,$path2,$path3,$check

$pcname=InputBox("Remote Cleaning","Enter the name of the computer to delete temporary files from,including \\:")
$user=InputBox("Remote Cleaning","Account that needs cleaning on the remote pc:")

$path=$pcname & "\c$\Documents and Settings\" & $user

FileChangeDir($path)
    
$path1=$path & "\UserData\"
$path2=$path & "\Local Settings\Temp\"
$path3=$path & "\Local Settings\Temporary Internet Files\"
    
FileDelete($path1 & "*.*")
FileDelete($path2 & "*.*")
FileDelete($path3 & "*.*")
$check=$pcname & "--" & $user

MsgBox(0,"Remote Cleaning","Finished cleaning " & $check & @LF & @LF & $path1 & @LF & $path2 & @LF & $path3)

Exit

Share this post


Link to post
Share on other sites



drx,

Please do not bump your posts within 24 hours. :x

Remember this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. :P

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

First of all, you'll need your "whacks" in front of your computername

$Path = '\\' & $Pcname & "\c$\Documents and Settings\" & $User

Secondly, the files that you are trying to delete are located in special folders that at a minimum require local admin privileges to delete, and even if you have the proper authority, they may be in use. If you are certain that the your account has Admin access to the machines that you are trying to clean, you may have locked-file(s) issue(s).

Share this post


Link to post
Share on other sites

I do have privileges to these files. I can access the pc from run cmd, and delete them manually as i please, so they also should not be locked. When i run this script, it asks for you to include the \\ with the computer name. Also, the last msgbox shows what my variables are in the end, i.e.

\\1.1.1.1\c$\documents and settings\myuser\local settings\temp

This shows that the directories that FileDelete() are using are correct. Does FileDelete not use the all wildcard, *.*, correctly? Or is this not the best command to use?

Share this post


Link to post
Share on other sites

I do have privileges to these files. I can access the pc from run cmd, and delete them manually as i please, so they also should not be locked. When i run this script, it asks for you to include the \\ with the computer name. Also, the last msgbox shows what my variables are in the end, i.e.

\\1.1.1.1\c$\documents and settings\myuser\local settings\temp

This shows that the directories that FileDelete() are using are correct. Does FileDelete not use the all wildcard, *.*, correctly? Or is this not the best command to use?

Just looked in the help file and saw this note on the command.

Note: If the "path" passed to FileDelete is a folder, the files therein will be deleted just as if you had used the *.* mask.

Perhaps just omit the *.* then?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Try replacing the FileDelete() lines with @Comspec like this

RunWait(@ComSpec & ' /c del /q "' & $Path3 & '\*.*"', '', @SW_HIDE)
That was the only way I could get the files in the remote temp folder to delete. If I created a folder on the remote machine, FileDelete() would work.

Edited by Varian

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks Varian. But, I tried the code and it did not work. I am beginning to think my network hates me :[ Or the script one.......

Though, with that command, is there anything i need to #include?

Edited by drx

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I am concentrating on the remote user's temp folder for simplicity.

Can you delete the files from the command line? Just keep in mind, that not all the files will delete. You cannot even delete all the files in your own temp folder usually. Since you have access to to the remote user's profile folder, test by creating a new folder and throwing in some files into it. Try your script with that folder. If it works, you are looking at a permissions on "in use" issue, not a script issue.

EDIT: You could try using #RequireAdmin, but I'm not sure if that is the issue.

Edited by Varian

Share this post


Link to post
Share on other sites

Huh, you are correct. Though i can delete them at will within explorer, the script will not. How ever the file i create in just the c:\docu and sett\user\test are all deleted.....

Would the #RequireAdmin automatically ask for credentials?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Huh, you are correct. Though i can delete them at will within explorer, the script will not. How ever the file i create in just the c:\docu and sett\user\test are all deleted.....

Would the #RequireAdmin automatically ask for credentials?

Only if you are not a member of the local admin group on the computer on which you are working. Of course, even that account may not be a local admin on the remote computer, but if it is, I would put it there anyway.

EDIT:Have you tested deleting all the files from the command line or via a batch file? My guess is running:

del /q "\\remotecomputer\c$\documents and settings\username\Local Settings\Temp\*.*"
will throw a "cannot delete error" on a file or 2. Edited by Varian

Share this post


Link to post
Share on other sites

running on a command line, that does not delete anything, nor does it give me any errors.....

My credentials are under a group that has local admin rights on my local pc, the remote pc, as well as 90% of the pcs on my network, so I cannot make sense of this :/

:x

Share this post


Link to post
Share on other sites

Try this script and report your results

#RequireAdmin

Local $Pcname, $User, $Command, $File, $BatchFile = @TempDir & '\BatchDel.cmd'
$Pcname = InputBox("Remote Cleaning", "Enter the name of the computer to delete temporary files from,including \\:")
If @error Then Exit
$User = InputBox("Remote Cleaning", "Account that needs cleaning on the remote pc:")
If @error Then Exit

$Pcname = StringRegExpReplace($Pcname, '^(\\*)', '\\\\')    ;Replace all beginning "\" with "\\" or adds them if not there

Select
    Case FileExists($Pcname & '\c$\Documents and Settings\' & $User & '\Local Settings\Temp')
        $Command = $Pcname & '\c$\Documents and Settings\' & $User & '\Local Settings\Temp\*.*'
    Case FileExists($Pcname & '\c$\Users\' & $User & '\AppData\Local\Temp')
        $Command = $Pcname & '\c$\Users\' & $User & '\AppData\Local\Temp\*.*'
    Case Else
        Exit MsgBox(262160, 'FATAL ERROR', "Cannot Find Remote user's Temp Folder")
EndSelect
If Not $Command Then Exit

$File = FileOpen($BatchFile, 2)
FileWrite($File, 'del /s /q "' & $Command & '"'& @LF & 'pause')
FileClose($File)
Run($BatchFile, @TempDir, @SW_SHOW)

Share this post


Link to post
Share on other sites

Well, that defiantly deleted a few files with a command prompt, about twenty in total, and errored on one file that was in use, but no folders have been deleted.

Share this post


Link to post
Share on other sites

Folders are going to be really tough...I use a VB Script to delete my own temp folder periodically and lots of time the folders cannot be deleted, only marked for deletion on the next reboot. Give me a sec and I'll whip up something that can get you as close as possible.

Share this post


Link to post
Share on other sites

you'd think with local admin rights it would work. I can understand if there was a UAC involved....

Share this post


Link to post
Share on other sites

Here is something to try. It creates a CMD file that deletes files first then folders. I assume that XP or whatever OS you are using has "rmdir" to delete directories. You can check that by opening a command prompt and typing "rmdir /?" in there. Make sure that there is also a "/Q" option.

Let me know how it goes for you. If it works, you can add your other folders with concatenation on the $String variable in the main section...ie

$String = MakeBatch($Path)
$String &= @CRLF & MakeBatch($Pcname & '\c$\Documents and Settings\' & $User & '\Some other Folder')
#RequireAdmin
#include <Array.au3>
Opt('MustDeclareVars', 1)

Local $Pcname, $User, $Path, $File, $String, $BatchFile = @TempDir & '\BatchDel.cmd'
$Pcname = InputBox("Remote Cleaning", "Enter the name of the computer to delete temporary files from,including \\:")
If @error Then Exit
$User = InputBox("Remote Cleaning", "Account that needs cleaning on the remote pc:")
If @error Then Exit

$Pcname = StringRegExpReplace($Pcname, '^(\\*)', '\\\\') ;Replace all beginning "\" with "\\" or adds them if not there

Select
    Case FileExists($Pcname & '\c$\Documents and Settings\' & $User & '\Local Settings\Temp')
        $Path = $Pcname & '\c$\Documents and Settings\' & $User & '\Local Settings\Temp'
    Case FileExists($Pcname & '\c$\Users\' & $User & '\AppData\Local\Temp')
        $Path = $Pcname & '\c$\Users\' & $User & '\AppData\Local\Temp'
    Case Else
        Exit MsgBox(262160, 'FATAL ERROR', "Cannot Find Remote user's Temp Folder")
EndSelect
If Not $Path Then Exit

$String = MakeBatch($Path)
$File = FileOpen($BatchFile, 2)
FileWrite($File, $String)
FileClose($File)
MsgBox(0, '', $String) ;show resultant string
ShellExecute($BatchFile, '', @TempDir, 'edit') ;show contents of batchfile

Run($BatchFile, @TempDir, @SW_SHOW)

Func MakeBatch($Dir)
    Local $Array, $String
    $Array = _FileListToArrayRecursive($Dir, '*')
    If Not $Array[1] Then Exit
    For $i = 1 To $Array[0]
        Switch _IsDir($Array[$i])
            Case 'File'
                $Array[$i] = 'del /q "' & $Array[$i] & '"'
            Case 'Directory'
                $Array[$i] = 'rmdir /q "' & $Array[$i] & '"'
        EndSwitch
    Next
    _ArraySort($Array)
    For $i = 1 To $Array[0]
        $String &= $Array[$i] & @CRLF
    Next
    $String &= 'pause'
    Return $String
EndFunc   ;==>MakeBatch

Func _IsDir($Dir = '') ;Returns Directory, File, or Bad
    If StringRight($Dir, 1) = '\' Then $Dir = StringTrimRight($Dir, 1)
    If Not FileExists($Dir) Then Return 'Bad'
    If StringInStr(FileGetAttrib($Dir), 'D') <> 0 Then Return 'Directory'
    Return 'File'
EndFunc   ;==>_IsDir

;===============================================================================
;
; Description:      lists all files and folders in a specified path
; Syntax:           _FileListToArrayRecursive($S_Path, $s_Filter = "*", $I_Flag = 0)
; Parameter(s):     $s_Path = Path to generate filelist for
;                   $s_Filter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $i_Flag = determines whether to return file or folders or both
;                       $i_Flag=0(Default) Return both files and folders
;                       $i_Flag=1 Return files Only
;                       $i_Flag=2 Return Folders Only
;                   $i_Recurse = Indicate whether recursion to subfolders required
;                       $i_Recurse=0(Default) No recursion to subfolders
;                       $i_Recurse=1 recursion to subfolders
;                   $i_BaseDir = Indicate whether base directory name included in returned elements
;                       $i_BaseDir=0 base directory name not included
;                       $i_BaseDir=1 (Default) base directory name included
;                   $s_Exclude= The Exclude filter to use.  "WildCards" For details
;
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                       @Error=3 Invalid $i_Flag
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc <randallc@Ozemail.com.au>; modified from SolidSnake and big_Daddy and SmoKE_N and GEOsoft!
; Note(s):          The array returned is one-dimensional and is made up as follows:
;                   $Array[0] = Number of Files\Folders returned
;                   $array[1] = 1st File\Folder
;                   $array[2] = 2nd File\Folder
;                   $array[3] = 3rd File\Folder
;                   $array[n] = nth File\Folder
;
;===============================================================================
Func _FileListToArrayRecursive($sPath, $sFilter = "*", $iFlag = 0, $iRecurse = 1, $iBaseDir = 1, $Sexclude = '', $i_Deleteduplicate = 1)

    ;Declare local variables
    Local $sFileString, $AsList[1], $sep = "|", $sFileString1, $sFilter1 = $sFilter;$hSearch, $sFile,

    ;Set default filter to wildcard
    If $sFilter = -1 Or $sFilter == "" Or $sFilter = Default Then $sFilter = "*"

    ;Strip trailing slash from search path
    If StringRight($sPath, 1) == "\" Then $sPath = StringTrimRight($sPath, 1)

    ;Ensure search path exists
    If Not FileExists($sPath) Then Return SetError(1, 1, "")

    ;Return error if special characters are found in filter
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")

    ;Only allow 0,1,2 for flag options
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "");~     $sFilter = StringReplace("*" & $sFilter & "*", "**", "*")

    ;Determine seperator character
    If StringInStr($sFilter, ';') Then $sep = ";" ;$sFilter &= ';'
    If StringInStr($sFilter, ',') Then $sep = "," ;$sFilter &= ';'

    ;Append pipe to file filter if no semi-colons and pipe symbols are found
    $sFilter &= $sep

    ;Declare local variables, Implode file filter
    Local $aFilterSplit = StringSplit(StringStripWS($sFilter, 8), $sep), $sHoldSplit, $arFolders[2] = [$sPath, ""];~     $Cw = ConsoleWrite("UBound($aFilterSplit) =" & UBound($aFilterSplit) & @Lf)

    If $Sexclude <> "" Then $Sexclude = "(?i)(^" & StringReplace(StringReplace(StringReplace($Sexclude, ".", "\."), "*", ".*"), "?", ".") & "$)" ;change the filters to RegExp filters

    ;If recursion is desired, build an array of all sub-folders in search path (eliminates the need to run a conditional statement against FileAttrib)
    If $iRecurse Then;$cw = ConsoleWrite("UBound($aFilterSplit) =" & UBound($aFilterSplit) & @LF)

        ;if folders only,  build string ($sFileString1) of foldernames within search path, recursion and exclusion options are passed from main function
        If $iFlag = 2 Then _FileListToArrayRecursiveFolders1($sPath, $sFileString1, "*", $iRecurse, $Sexclude)

        ;if not folders only,  Build string ($sFileString1) of foldernames within search path, recursion (not exclusion, as would exclude some folders from subsequent filesearch) options are passed from main function
        If $iFlag <> 2 And StringTrimRight($sFilter, 1) <> "*" And StringTrimRight($sFilter, 1) <> "*.*" Then
            _FileListToArrayRecursiveFolders1($sPath, $sFileString1, "*", $iRecurse, "")

            ;Implode folder string
            $arFolders = StringSplit(StringTrimRight($sFileString1, 1), "*")

            ;Store search path in first element
            $arFolders[0] = $sPath
        EndIf
    EndIf
    If $iFlag <> 2 And (StringTrimRight($sFilter, 1) == "*" Or StringTrimRight($sFilter, 1) == "*.*") And $iRecurse Then
        If $iFlag = 1 Then
            _FileListToArrayRecursiveRecFiles1($sPath, $sFileString, "*")
        ElseIf $iFlag = 0 Then
            _FileListToArrayRecursiveRecAll1($sPath, $sFileString, "*")
        EndIf
    Else;If ($iFlag <> 2) then

        ;Loop through folder array
        For $iCF = 0 To UBound($arFolders) - 1;    $cw = ConsoleWrite("$iCF=" & $iCF & " $arFolders[$iCF]    =" & @LF & $arFolders[$iCF] & @LF)

            ;Verify folder name isn't just whitespace
            If StringStripWS($arFolders[$iCF], 8) = '' Then ContinueLoop

            ;Loop through file filters
            For $iCC = 1 To UBound($aFilterSplit) - 1

                ;Verify file filter isn't just whitespace
                If StringStripWS($aFilterSplit[$iCC], 8) = '' Then ContinueLoop

                ;Append asterisk to file filter if a period is leading
                If StringLeft($aFilterSplit[$iCC], 1) == "." Then $aFilterSplit[$iCC] = "*" & $aFilterSplit[$iCC] ;, "**", "*")

                ;Replace multiple asterisks in file filter
                $sFilter = StringReplace("*" & $sFilter & "*", "**", "*")
                Select; options for not recursing; quicker than filtering after for single directory

                    ;Below needs work, _FileListToArrayRecursiveBrief1a and _FileListToArrayRecursiveBrief2a
                    ;should be consolidated with an option passed for the files / folders flag [says Ultima -but slower?]

                    ;Fastest, Not $iRecurse with with files and folders(? was written files only; just Not $iBaseDir), not recursed
                    Case Not $iRecurse And Not $iFlag And Not $iBaseDir
                        _FileListToArrayRecursiveBrief2a($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $Sexclude)

                        ;Not $iRecurse and  And $iBaseDir ;fast, with files and folders, not recursed
                    Case Not $iFlag
                        _FileListToArrayRecursiveBrief1a($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $Sexclude)

                        ;Fast, with files only,  not recursed
                    Case $iFlag = 1
                        _FileListToArrayRecursiveFiles1($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $Sexclude)

                        ;Folders only , not recursed
                    Case Not $iRecurse And $iFlag = 2
                        _FileListToArrayRecursiveFolders1($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $iRecurse, $Sexclude)
                EndSelect;$cw = ConsoleWrite("$iCC=" & $iCC & " $sFileString    =" & @LF & $sFileString & @LF)

                ;Append pipe symbol and current file filter onto $sHoldSplit ???????
                If $iCF = 0 Then $sHoldSplit &= $sep & $aFilterSplit[$iCC]; $cw = ConsoleWrite("$iCC=" & $iCC & " $sFileString    =" & @LF & $sFileString & @LF)
            Next

            ;Replace multiple asterisks
            If $iCF = 0 Then $sFilter = StringReplace(StringTrimLeft($sHoldSplit, 1), "**", "*");,$cw = ConsoleWrite("$iCC=" & $iCC & " $sFilter    =" & @LF & $sFilter & @LF)
        Next
    EndIf
    ;Below needs work....

    ;If recursive, folders-only, and filter ins't a wildcard
    If $iRecurse And ($iFlag = 2) And StringTrimRight($sFilter, 1) <> "*" And StringTrimRight($sFilter, 1) <> "*.*" And Not StringInStr($sFilter, "**") Then ; filter folders -------------------

        ;Trim trailing character
        $sFileString1 = StringTrimRight(StringReplace($sFileString1, "*", @LF), 1)

        ;Change the filters to RegExp filters
        $sFilter1 = StringReplace(StringReplace(StringReplace($sFilter1, ".", "\."), "*", ".*"), "?", ".")
        Local $Pattern = '(?m)(^(?i)' & $sFilter1 & '$)' ;, $cw = ConsoleWrite("$sFilter    =" & @LF & $sFilter1 & @LF), $cw = ConsoleWrite("$pattern    =" & @LF & $pattern & @LF)
        $AsList = StringRegExp($sFileString1, $Pattern, 3)

        ;If only relative file / folder names are desired
        If (Not $iBaseDir) Then

            ; past ARRAY.AU3 DEPENDENCY
            $sFileString1 = _ArrayToString1($AsList, "*")
            $sFileString1 = StringReplace($sFileString1, $sPath & "\", "", 0, 2)
            $AsList = StringSplit($sFileString1, "*")
        EndIf
    ElseIf $iRecurse And ($iFlag = 2) Then
        $sFileString = StringStripCR($sFileString1)
    EndIf;If UBound($asList) > 1 Then ConsoleWrite("$asList[1]     =" & @LF & $asList[1] & @LF);~

    ;past ARRAY.AU3 DEPENDENCY
    If IsArray($AsList) And UBound($AsList) > 0 And $AsList[0] <> "" And Not IsNumber($AsList[0]) Then _ArrayInsert1($AsList, 0, UBound($AsList))
    If IsArray($AsList) And UBound($AsList) > 1 And $AsList[0] <> "" Then Return $AsList
    If (Not $iBaseDir) Or (Not $iRecurse And Not $iFlag And Not $iBaseDir) Then $sFileString = StringReplace($sFileString, $sPath & "\", "", 0, 2)
    Local $arReturn = StringSplit(StringTrimRight($sFileString, 1), "*");~     local $A=ConsoleWrite("$sFileString :"&@lf&StringReplace($sFileString,"|",@Crlf)&@lf),$Timerstamp1=TimerInit()
    If $i_Deleteduplicate And IsArray($arReturn) And UBound($arReturn) > 1 And $arReturn[1] <> "" And Not (UBound($aFilterSplit) = 3 And $aFilterSplit[2] == "") Then _ArrayDeleteDupes1($arReturn);and  $arFolders[1]<>""
    Return $arReturn;~     Return StringSplit(StringTrimRight($sFileString, 1), "*")
EndFunc   ;==>_FileListToArrayRecursive
;===============================================================================
;
; Description:  _ArrayDeleteDupes1; deletes duplicates in an Array 1D
; Syntax:           _ArrayDeleteDupes1(ByRef $ar_Array)
; Parameter(s):     $ar_Array = 1d Array
; Requirement(s):   None
; Return Value(s):  On Success - Returns asorted array with no duplicates
;                        On Failure -
;                       @Error=1 P
;                       @Error=2
;
; Author(s):        randallc
;===============================================================================
Func _ArrayDeleteDupes1(ByRef $arrItems)
    If @OSType = "WIN32_WINDOWS" Then Return 0
    Local $i = 0, $ObjDictionary = ObjCreate("Scripting.Dictionary")
    For $StrItem In $arrItems
        If Not $ObjDictionary.Exists($StrItem) Then
            $ObjDictionary.Add($StrItem, $StrItem)
        EndIf
    Next
    ReDim $arrItems[$ObjDictionary.Count]
    For $strKey In $ObjDictionary.Keys
        $arrItems[$i] = $strKey
        $i += 1
    Next
    $arrItems[0] = $ObjDictionary.Count - 1
    Return 1
EndFunc   ;==>_ArrayDeleteDupes1
;===============================================================================
;
; Description:      Helper  self-calling func for  _FileListToArrayRecursive wrapper; lists all  folders in a specified path
; Syntax:           _FileListToArrayRecursiveFolders1($s_PathF, ByRef $s_FileStringF, $s_FilterF,  $i_RecurseF)
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all folders only in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $i_RecurseF = Indicate whether recursion to subfolders required
;                       $i_RecurseF=0(Default) No recursion to subfolders
;                       $i_RecurseF=1 recursion to subfolders
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                       @Error=3 Invalid $i_Flag
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveFolders1($sPathF, ByRef $sFileStringF, $sFilterF, $iRecurseF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then ;directories only wanted; and  the attrib shows is  directory
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
                If $iRecurseF = 1 Then _FileListToArrayRecursiveFolders1($sPathF2, $sFileStringF, $sFilterF, $iRecurseF)
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF; if folders only and this pattern matches exclude pattern, no further list or subdir
            If StringRegExp($sPathF2, $sExcludeF) Then ContinueLoop
            If StringInStr(FileGetAttrib($sPathF2), "D") Then ;directories only wanted; and  the attrib shows is  directory
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter with * as delimiter
                If $iRecurseF = 1 Then _FileListToArrayRecursiveFolders1($sPathF2, $sFileStringF, $sFilterF, $iRecurseF, $sExcludeF)
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveFolders1
Func RecursiveFileSearchC($startDir, $rFSpattern = "*", $Exclude = "", $Depth = 0)
;~  If StringRight($startDir, 1) <> "\"  Then $startDir &= "\"
    If StringRight($startDir, 1) == "\" Then $startDir = StringTrimRight($startDir, 1)

    If $Depth = 0 Then
        ;change filters to RegExp filters
        If $rFSpattern <> "" Then $rFSpattern = "(?i)(^" & StringReplace(StringReplace(StringReplace($rFSpattern, ".", "\."), "*", ".*"), "?", ".") & "$)" ;change the filters to RegExp filters
        If $Exclude <> "" Then $Exclude = "(?i)(^" & StringReplace(StringReplace(StringReplace($Exclude, ".", "\."), "*", ".*"), "?", ".") & "$)" ;change the filters to RegExp filters

        ;Get count of all files in subfolders
        Local $RFSfilecount = DirGetSize($startDir, 1)
        Global $RFSarray[$RFSfilecount[1] + 1]
    EndIf

    Local $search = FileFindFirstFile($startDir & "\*.*")
    If @error Then Return

    ;Search through all files and folders in directory
    While 1
        Local $Next = FileFindNextFile($search)
        If @error Then ExitLoop

        ;If folder, recurse
        If StringInStr(FileGetAttrib($startDir & "\" & $Next), "D") Then
            RecursiveFileSearchC($startDir & "\" & $Next, $rFSpattern, $Exclude, $Depth + 1)
        Else
            If StringRegExp($Next, $rFSpattern, 0) And Not StringRegExp($Next, $Exclude, 0) Then
                ;Append filename to array
                $RFSarray[$RFSarray[0] + 1] = $startDir & "\" & $Next

                ;Increment filecount
                $RFSarray[0] += 1
            EndIf
        EndIf
    WEnd
    FileClose($search)

    If $Depth = 0 Then
        ReDim $RFSarray[$RFSarray[0] + 1]
        Return $RFSarray
    EndIf
EndFunc   ;==>RecursiveFileSearchC
;
; Description:      Helper  func for  _FileListToArrayRecursive wrapper; lists all files in a specified path
; Syntax:           _FileListToArrayRecursiveFiles1($s_PathF, ByRef $s_FileStringF, $s_FilterF) ;quick as not recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveFiles1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF;directories not wanted; and  the attrib shows not  directory
            If Not StringInStr(FileGetAttrib($sPathF2), "D") Then
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF;directories not wanted; and  the attrib shows not  directory; and filename [only]  does not match exclude
            If Not StringInStr(FileGetAttrib($sPathF2), "D") _
                    And Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveFiles1
;===============================================================================
;
; Description:      Helper  self-calling func for  _FileListToArrayRecursive wrapper; lists all files and folders in a specified path, recursive
; Syntax:           _FileListToArrayRecursiveRecFiles1($s_PathF, ByRef $s_FileStringF, $s_FilterF) ; recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveRecAll1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            If StringInStr(FileGetAttrib($sPathF2), "D") Then _FileListToArrayRecursiveRecAll1($sPathF2, $sFileStringF, $sFilterF);, $iFlagF, $iRecurseF)
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                $sFileStringF &= $sPathF2 & "*" ;this writes the directoryname
                _FileListToArrayRecursiveRecAll1($sPathF2, $sFileStringF, $sFilterF, $sExcludeF);, $iFlagF, $iRecurseF)
            Else ;if not directory, check Exclude match
                If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveRecAll1
;===============================================================================
;
; Description:      Helper  self-calling func for  _FileListToArrayRecursive wrapper; lists all files  in a specified path, recursive
; Syntax:           _FileListToArrayRecursiveRecFiles1($s_PathF, ByRef $s_FileStringF, $s_FilterF) ; recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveRecFiles1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRecursiveRecFiles1($sPathF2, $sFileStringF, $sFilterF);, $iFlagF, $iRecurseF)
            Else
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRecursiveRecFiles1($sPathF2, $sFileStringF, $sFilterF, $sExcludeF);, $iFlagF, $iRecurseF)
            Else
                If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveRecFiles1
;===============================================================================
;
; Description:      Helper  func for  _FileListToArrayRecursive wrapper; ;Fastest, Not $iRecurse with with files and folders(? was written files only; just Not $iBaseDir), not recursed
; Syntax:           _FileListToArrayRecursiveBrief2a($s_PathF, ByRef $s_FileStringF, $s_FilterF) ;quick as not recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveBrief2a($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sFileStringF &= $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter; only time no full path included
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            ;If not StringRegExp($sFileF,$sExcludeF) then $sFileStringF &= $sPathF2 & "*"
            If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter; only time no full path included
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveBrief2a
;===============================================================================
;
; Description:      Helper  func for  _FileListToArrayRecursive wrapper; lists all files and folders in a specified path, not recursive
; Syntax:           _FileListToArrayRecursiveBrief1a($s_PathF, ByRef $s_FileStringF, $s_FilterF) ;quick as not recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveBrief1a($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sFileStringF &= $sPathF & "\" & $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter [remo]
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF & "\" & $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter [remo]
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveBrief1a
Func _ArrayToString1(Const ByRef $AvArray, $sDelim = "|", $iStart = 0, $iEnd = 0)
    If Not IsArray($AvArray) Then Return SetError(1, 0, "")

    Local $sResult, $iUBound = UBound($AvArray) - 1

    ; Bounds checking
    If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound
    If $iStart < 0 Then $iStart = 0
    If $iStart > $iEnd Then Return SetError(2, 0, "")

    ; Combine
    For $i = $iStart To $iEnd
        $sResult &= $AvArray[$i] & $sDelim
    Next

    Return StringTrimRight($sResult, StringLen($sDelim))
EndFunc   ;==>_ArrayToString1
Func _ArrayInsert1(ByRef $AvArray, $iElement, $vValue = "")
    If Not IsArray($AvArray) Then Return SetError(1, 0, 0)

    ; Add 1 to the array
    Local $iUBound = UBound($AvArray) + 1
    ReDim $AvArray[$iUBound]

    ; Move all entries over til the specified element
    For $i = $iUBound - 1 To $iElement + 1 Step -1
        $AvArray[$i] = $AvArray[$i - 1]
    Next

    ; Add the value in the specified element
    $AvArray[$iElement] = $vValue
    Return $iUBound
EndFunc   ;==>_ArrayInsert1

Share this post


Link to post
Share on other sites

That is a long script! Buuuut....it looks like it worked as i needed, aside from directories and files in use! I will edit it to my needs with other folders....one question though, what exaclty is this scriplet for::

$String = MakeBatch($Path)

$String &= @CRLF & MakeBatch($Pcname & '\c$\Documents and Settings\' & $User & '\Some other Folder')

Share this post


Link to post
Share on other sites

That is a long script! Buuuut....it looks like it worked as i needed, aside from directories and files in use! I will edit it to my needs with other folders....one question though, what exaclty is this scriplet for::

$String = MakeBatch($Path)

$String &= @CRLF & MakeBatch($Pcname & '\c$\Documents and Settings\' & $User & '\Some other Folder')

That was one example of how you could add more directories as long as the script did what you wanted it to. I would suggest, however, that you modify the script so that:

After getting the $PCname & $User:

you create an array containing all of the folders that you want to touch

Loop through this array calling the makebatch() function for each element, thusly making the batch file for each folder. As for the length, I did not create the _FileListToArrayRecursive() function, just one I got here from another user. But it works without using Array.au3, so I have kept using it.

#RequireAdmin
#include <Array.au3>
Opt('MustDeclareVars', 1)

Local $Pcname, $User, $Path, $File, $String, $BatchFile = @TempDir & '\BatchDel.cmd'
$Pcname = InputBox("Remote Cleaning", "Enter the name of the computer to delete temporary files from,including \\:")
If @error Then Exit
$User = InputBox("Remote Cleaning", "Account that needs cleaning on the remote pc:")
If @error Then Exit

$Pcname = StringRegExpReplace($Pcname, '^(\\*)', '\\\\') ;Replace all beginning "\" with "\\" or adds them if not there

$Path = $Pcname & '\c$\Documents and Settings\' & $User

Local $Directories[3] = [$Path & '\UserData', $Path & '\Local Settings\Temp', $Path & '\Local Settings\Temporary Internet Files']

For $Element In $Directories
    $String = MakeBatch($Element)
    If Not $String Then ContinueLoop
    $File = FileOpen($BatchFile, 2)
    FileWrite($File, $String)
    FileClose($File)
    ;Comment out the Next 2 lines when you feel comfortable with the script
    MsgBox(0, '', $String) ;show resultant string
    ShellExecuteWait($BatchFile, '', @TempDir, 'edit') ;show contents of batchfile
    RunWait($BatchFile, @TempDir, @SW_SHOW) ;Change @SW_SHOW to @SW_HIDE when you feel comfortable with the Script
Next


Func MakeBatch($Dir)
    Local $Array, $String
    If Not FileExists($Dir) Then Return
    $Array = _FileListToArrayRecursive($Dir, '*')
    If Not $Array[1] Then Return
    For $i = 1 To $Array[0]
        Switch _IsDir($Array[$i])
            Case 'File'
                $Array[$i] = 'del /q "' & $Array[$i] & '"'
            Case 'Directory'
                $Array[$i] = 'rmdir /q "' & $Array[$i] & '"'
        EndSwitch
    Next
    _ArraySort($Array)
    For $i = 1 To $Array[0]
        $String &= $Array[$i] & @CRLF
    Next
    $String &= 'pause'
    Return $String
EndFunc   ;==>MakeBatch

Func _IsDir($Dir = '') ;Returns Directory, File, or Bad
    If StringRight($Dir, 1) = '\' Then $Dir = StringTrimRight($Dir, 1)
    If Not FileExists($Dir) Then Return 'Bad'
    If StringInStr(FileGetAttrib($Dir), 'D') <> 0 Then Return 'Directory'
    Return 'File'
EndFunc   ;==>_IsDir

;===============================================================================
;
; Description:      lists all files and folders in a specified path
; Syntax:           _FileListToArrayRecursive($S_Path, $s_Filter = "*", $I_Flag = 0)
; Parameter(s):     $s_Path = Path to generate filelist for
;                   $s_Filter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $i_Flag = determines whether to return file or folders or both
;                       $i_Flag=0(Default) Return both files and folders
;                       $i_Flag=1 Return files Only
;                       $i_Flag=2 Return Folders Only
;                   $i_Recurse = Indicate whether recursion to subfolders required
;                       $i_Recurse=0(Default) No recursion to subfolders
;                       $i_Recurse=1 recursion to subfolders
;                   $i_BaseDir = Indicate whether base directory name included in returned elements
;                       $i_BaseDir=0 base directory name not included
;                       $i_BaseDir=1 (Default) base directory name included
;                   $s_Exclude= The Exclude filter to use.  "WildCards" For details
;
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                       @Error=3 Invalid $i_Flag
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc <randallc@Ozemail.com.au>; modified from SolidSnake and big_Daddy and SmoKE_N and GEOsoft!
; Note(s):          The array returned is one-dimensional and is made up as follows:
;                   $Array[0] = Number of Files\Folders returned
;                   $array[1] = 1st File\Folder
;                   $array[2] = 2nd File\Folder
;                   $array[3] = 3rd File\Folder
;                   $array[n] = nth File\Folder
;
;===============================================================================
Func _FileListToArrayRecursive($sPath, $sFilter = "*", $iFlag = 0, $iRecurse = 1, $iBaseDir = 1, $Sexclude = '', $i_Deleteduplicate = 1)

    ;Declare local variables
    Local $sFileString, $AsList[1], $sep = "|", $sFileString1, $sFilter1 = $sFilter;$hSearch, $sFile,

    ;Set default filter to wildcard
    If $sFilter = -1 Or $sFilter == "" Or $sFilter = Default Then $sFilter = "*"

    ;Strip trailing slash from search path
    If StringRight($sPath, 1) == "\" Then $sPath = StringTrimRight($sPath, 1)

    ;Ensure search path exists
    If Not FileExists($sPath) Then Return SetError(1, 1, "")

    ;Return error if special characters are found in filter
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")

    ;Only allow 0,1,2 for flag options
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "");~     $sFilter = StringReplace("*" & $sFilter & "*", "**", "*")

    ;Determine seperator character
    If StringInStr($sFilter, ';') Then $sep = ";" ;$sFilter &= ';'
    If StringInStr($sFilter, ',') Then $sep = "," ;$sFilter &= ';'

    ;Append pipe to file filter if no semi-colons and pipe symbols are found
    $sFilter &= $sep

    ;Declare local variables, Implode file filter
    Local $aFilterSplit = StringSplit(StringStripWS($sFilter, 8), $sep), $sHoldSplit, $arFolders[2] = [$sPath, ""];~     $Cw = ConsoleWrite("UBound($aFilterSplit) =" & UBound($aFilterSplit) & @Lf)

    If $Sexclude <> "" Then $Sexclude = "(?i)(^" & StringReplace(StringReplace(StringReplace($Sexclude, ".", "\."), "*", ".*"), "?", ".") & "$)" ;change the filters to RegExp filters

    ;If recursion is desired, build an array of all sub-folders in search path (eliminates the need to run a conditional statement against FileAttrib)
    If $iRecurse Then;$cw = ConsoleWrite("UBound($aFilterSplit) =" & UBound($aFilterSplit) & @LF)

        ;if folders only,  build string ($sFileString1) of foldernames within search path, recursion and exclusion options are passed from main function
        If $iFlag = 2 Then _FileListToArrayRecursiveFolders1($sPath, $sFileString1, "*", $iRecurse, $Sexclude)

        ;if not folders only,  Build string ($sFileString1) of foldernames within search path, recursion (not exclusion, as would exclude some folders from subsequent filesearch) options are passed from main function
        If $iFlag <> 2 And StringTrimRight($sFilter, 1) <> "*" And StringTrimRight($sFilter, 1) <> "*.*" Then
            _FileListToArrayRecursiveFolders1($sPath, $sFileString1, "*", $iRecurse, "")

            ;Implode folder string
            $arFolders = StringSplit(StringTrimRight($sFileString1, 1), "*")

            ;Store search path in first element
            $arFolders[0] = $sPath
        EndIf
    EndIf
    If $iFlag <> 2 And (StringTrimRight($sFilter, 1) == "*" Or StringTrimRight($sFilter, 1) == "*.*") And $iRecurse Then
        If $iFlag = 1 Then
            _FileListToArrayRecursiveRecFiles1($sPath, $sFileString, "*")
        ElseIf $iFlag = 0 Then
            _FileListToArrayRecursiveRecAll1($sPath, $sFileString, "*")
        EndIf
    Else;If ($iFlag <> 2) then

        ;Loop through folder array
        For $iCF = 0 To UBound($arFolders) - 1;    $cw = ConsoleWrite("$iCF=" & $iCF & " $arFolders[$iCF]    =" & @LF & $arFolders[$iCF] & @LF)

            ;Verify folder name isn't just whitespace
            If StringStripWS($arFolders[$iCF], 8) = '' Then ContinueLoop

            ;Loop through file filters
            For $iCC = 1 To UBound($aFilterSplit) - 1

                ;Verify file filter isn't just whitespace
                If StringStripWS($aFilterSplit[$iCC], 8) = '' Then ContinueLoop

                ;Append asterisk to file filter if a period is leading
                If StringLeft($aFilterSplit[$iCC], 1) == "." Then $aFilterSplit[$iCC] = "*" & $aFilterSplit[$iCC] ;, "**", "*")

                ;Replace multiple asterisks in file filter
                $sFilter = StringReplace("*" & $sFilter & "*", "**", "*")
                Select; options for not recursing; quicker than filtering after for single directory

                    ;Below needs work, _FileListToArrayRecursiveBrief1a and _FileListToArrayRecursiveBrief2a
                    ;should be consolidated with an option passed for the files / folders flag [says Ultima -but slower?]

                    ;Fastest, Not $iRecurse with with files and folders(? was written files only; just Not $iBaseDir), not recursed
                    Case Not $iRecurse And Not $iFlag And Not $iBaseDir
                        _FileListToArrayRecursiveBrief2a($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $Sexclude)

                        ;Not $iRecurse and  And $iBaseDir ;fast, with files and folders, not recursed
                    Case Not $iFlag
                        _FileListToArrayRecursiveBrief1a($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $Sexclude)

                        ;Fast, with files only,  not recursed
                    Case $iFlag = 1
                        _FileListToArrayRecursiveFiles1($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $Sexclude)

                        ;Folders only , not recursed
                    Case Not $iRecurse And $iFlag = 2
                        _FileListToArrayRecursiveFolders1($arFolders[$iCF], $sFileString, $aFilterSplit[$iCC], $iRecurse, $Sexclude)
                EndSelect;$cw = ConsoleWrite("$iCC=" & $iCC & " $sFileString    =" & @LF & $sFileString & @LF)

                ;Append pipe symbol and current file filter onto $sHoldSplit ???????
                If $iCF = 0 Then $sHoldSplit &= $sep & $aFilterSplit[$iCC]; $cw = ConsoleWrite("$iCC=" & $iCC & " $sFileString    =" & @LF & $sFileString & @LF)
            Next

            ;Replace multiple asterisks
            If $iCF = 0 Then $sFilter = StringReplace(StringTrimLeft($sHoldSplit, 1), "**", "*");,$cw = ConsoleWrite("$iCC=" & $iCC & " $sFilter    =" & @LF & $sFilter & @LF)
        Next
    EndIf
    ;Below needs work....

    ;If recursive, folders-only, and filter ins't a wildcard
    If $iRecurse And ($iFlag = 2) And StringTrimRight($sFilter, 1) <> "*" And StringTrimRight($sFilter, 1) <> "*.*" And Not StringInStr($sFilter, "**") Then ; filter folders -------------------

        ;Trim trailing character
        $sFileString1 = StringTrimRight(StringReplace($sFileString1, "*", @LF), 1)

        ;Change the filters to RegExp filters
        $sFilter1 = StringReplace(StringReplace(StringReplace($sFilter1, ".", "\."), "*", ".*"), "?", ".")
        Local $Pattern = '(?m)(^(?i)' & $sFilter1 & '$)' ;, $cw = ConsoleWrite("$sFilter    =" & @LF & $sFilter1 & @LF), $cw = ConsoleWrite("$pattern    =" & @LF & $pattern & @LF)
        $AsList = StringRegExp($sFileString1, $Pattern, 3)

        ;If only relative file / folder names are desired
        If (Not $iBaseDir) Then

            ; past ARRAY.AU3 DEPENDENCY
            $sFileString1 = _ArrayToString1($AsList, "*")
            $sFileString1 = StringReplace($sFileString1, $sPath & "\", "", 0, 2)
            $AsList = StringSplit($sFileString1, "*")
        EndIf
    ElseIf $iRecurse And ($iFlag = 2) Then
        $sFileString = StringStripCR($sFileString1)
    EndIf;If UBound($asList) > 1 Then ConsoleWrite("$asList[1]     =" & @LF & $asList[1] & @LF);~

    ;past ARRAY.AU3 DEPENDENCY
    If IsArray($AsList) And UBound($AsList) > 0 And $AsList[0] <> "" And Not IsNumber($AsList[0]) Then _ArrayInsert1($AsList, 0, UBound($AsList))
    If IsArray($AsList) And UBound($AsList) > 1 And $AsList[0] <> "" Then Return $AsList
    If (Not $iBaseDir) Or (Not $iRecurse And Not $iFlag And Not $iBaseDir) Then $sFileString = StringReplace($sFileString, $sPath & "\", "", 0, 2)
    Local $arReturn = StringSplit(StringTrimRight($sFileString, 1), "*");~     local $A=ConsoleWrite("$sFileString :"&@lf&StringReplace($sFileString,"|",@Crlf)&@lf),$Timerstamp1=TimerInit()
    If $i_Deleteduplicate And IsArray($arReturn) And UBound($arReturn) > 1 And $arReturn[1] <> "" And Not (UBound($aFilterSplit) = 3 And $aFilterSplit[2] == "") Then _ArrayDeleteDupes1($arReturn);and  $arFolders[1]<>""
    Return $arReturn;~     Return StringSplit(StringTrimRight($sFileString, 1), "*")
EndFunc   ;==>_FileListToArrayRecursive
;===============================================================================
;
; Description:  _ArrayDeleteDupes1; deletes duplicates in an Array 1D
; Syntax:           _ArrayDeleteDupes1(ByRef $ar_Array)
; Parameter(s):     $ar_Array = 1d Array
; Requirement(s):   None
; Return Value(s):  On Success - Returns asorted array with no duplicates
;                        On Failure -
;                       @Error=1 P
;                       @Error=2
;
; Author(s):        randallc
;===============================================================================
Func _ArrayDeleteDupes1(ByRef $arrItems)
    If @OSType = "WIN32_WINDOWS" Then Return 0
    Local $i = 0, $ObjDictionary = ObjCreate("Scripting.Dictionary")
    For $StrItem In $arrItems
        If Not $ObjDictionary.Exists($StrItem) Then
            $ObjDictionary.Add($StrItem, $StrItem)
        EndIf
    Next
    ReDim $arrItems[$ObjDictionary.Count]
    For $strKey In $ObjDictionary.Keys
        $arrItems[$i] = $strKey
        $i += 1
    Next
    $arrItems[0] = $ObjDictionary.Count - 1
    Return 1
EndFunc   ;==>_ArrayDeleteDupes1
;===============================================================================
;
; Description:      Helper  self-calling func for  _FileListToArrayRecursive wrapper; lists all  folders in a specified path
; Syntax:           _FileListToArrayRecursiveFolders1($s_PathF, ByRef $s_FileStringF, $s_FilterF,  $i_RecurseF)
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all folders only in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $i_RecurseF = Indicate whether recursion to subfolders required
;                       $i_RecurseF=0(Default) No recursion to subfolders
;                       $i_RecurseF=1 recursion to subfolders
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                       @Error=3 Invalid $i_Flag
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveFolders1($sPathF, ByRef $sFileStringF, $sFilterF, $iRecurseF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then ;directories only wanted; and  the attrib shows is  directory
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
                If $iRecurseF = 1 Then _FileListToArrayRecursiveFolders1($sPathF2, $sFileStringF, $sFilterF, $iRecurseF)
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF; if folders only and this pattern matches exclude pattern, no further list or subdir
            If StringRegExp($sPathF2, $sExcludeF) Then ContinueLoop
            If StringInStr(FileGetAttrib($sPathF2), "D") Then ;directories only wanted; and  the attrib shows is  directory
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter with * as delimiter
                If $iRecurseF = 1 Then _FileListToArrayRecursiveFolders1($sPathF2, $sFileStringF, $sFilterF, $iRecurseF, $sExcludeF)
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveFolders1
Func RecursiveFileSearchC($startDir, $rFSpattern = "*", $Exclude = "", $Depth = 0)
;~  If StringRight($startDir, 1) <> "\"  Then $startDir &= "\"
    If StringRight($startDir, 1) == "\" Then $startDir = StringTrimRight($startDir, 1)

    If $Depth = 0 Then
        ;change filters to RegExp filters
        If $rFSpattern <> "" Then $rFSpattern = "(?i)(^" & StringReplace(StringReplace(StringReplace($rFSpattern, ".", "\."), "*", ".*"), "?", ".") & "$)" ;change the filters to RegExp filters
        If $Exclude <> "" Then $Exclude = "(?i)(^" & StringReplace(StringReplace(StringReplace($Exclude, ".", "\."), "*", ".*"), "?", ".") & "$)" ;change the filters to RegExp filters

        ;Get count of all files in subfolders
        Local $RFSfilecount = DirGetSize($startDir, 1)
        Global $RFSarray[$RFSfilecount[1] + 1]
    EndIf

    Local $search = FileFindFirstFile($startDir & "\*.*")
    If @error Then Return

    ;Search through all files and folders in directory
    While 1
        Local $Next = FileFindNextFile($search)
        If @error Then ExitLoop

        ;If folder, recurse
        If StringInStr(FileGetAttrib($startDir & "\" & $Next), "D") Then
            RecursiveFileSearchC($startDir & "\" & $Next, $rFSpattern, $Exclude, $Depth + 1)
        Else
            If StringRegExp($Next, $rFSpattern, 0) And Not StringRegExp($Next, $Exclude, 0) Then
                ;Append filename to array
                $RFSarray[$RFSarray[0] + 1] = $startDir & "\" & $Next

                ;Increment filecount
                $RFSarray[0] += 1
            EndIf
        EndIf
    WEnd
    FileClose($search)

    If $Depth = 0 Then
        ReDim $RFSarray[$RFSarray[0] + 1]
        Return $RFSarray
    EndIf
EndFunc   ;==>RecursiveFileSearchC
;
; Description:      Helper  func for  _FileListToArrayRecursive wrapper; lists all files in a specified path
; Syntax:           _FileListToArrayRecursiveFiles1($s_PathF, ByRef $s_FileStringF, $s_FilterF) ;quick as not recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveFiles1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF;directories not wanted; and  the attrib shows not  directory
            If Not StringInStr(FileGetAttrib($sPathF2), "D") Then
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF;directories not wanted; and  the attrib shows not  directory; and filename [only]  does not match exclude
            If Not StringInStr(FileGetAttrib($sPathF2), "D") _
                    And Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveFiles1
;===============================================================================
;
; Description:      Helper  self-calling func for  _FileListToArrayRecursive wrapper; lists all files and folders in a specified path, recursive
; Syntax:           _FileListToArrayRecursiveRecFiles1($s_PathF, ByRef $s_FileStringF, $s_FilterF) ; recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveRecAll1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            If StringInStr(FileGetAttrib($sPathF2), "D") Then _FileListToArrayRecursiveRecAll1($sPathF2, $sFileStringF, $sFilterF);, $iFlagF, $iRecurseF)
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                $sFileStringF &= $sPathF2 & "*" ;this writes the directoryname
                _FileListToArrayRecursiveRecAll1($sPathF2, $sFileStringF, $sFilterF, $sExcludeF);, $iFlagF, $iRecurseF)
            Else ;if not directory, check Exclude match
                If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveRecAll1
;===============================================================================
;
; Description:      Helper  self-calling func for  _FileListToArrayRecursive wrapper; lists all files  in a specified path, recursive
; Syntax:           _FileListToArrayRecursiveRecFiles1($s_PathF, ByRef $s_FileStringF, $s_FilterF) ; recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveRecFiles1($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2, $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRecursiveRecFiles1($sPathF2, $sFileStringF, $sFilterF);, $iFlagF, $iRecurseF)
            Else
                $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRecursiveRecFiles1($sPathF2, $sFileStringF, $sFilterF, $sExcludeF);, $iFlagF, $iRecurseF)
            Else
                If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF2 & "*" ;this writes the filename to the delimited string with * as delimiter
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveRecFiles1
;===============================================================================
;
; Description:      Helper  func for  _FileListToArrayRecursive wrapper; ;Fastest, Not $iRecurse with with files and folders(? was written files only; just Not $iBaseDir), not recursed
; Syntax:           _FileListToArrayRecursiveBrief2a($s_PathF, ByRef $s_FileStringF, $s_FilterF) ;quick as not recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveBrief2a($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sFileStringF &= $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter; only time no full path included
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            ;If not StringRegExp($sFileF,$sExcludeF) then $sFileStringF &= $sPathF2 & "*"
            If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter; only time no full path included
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveBrief2a
;===============================================================================
;
; Description:      Helper  func for  _FileListToArrayRecursive wrapper; lists all files and folders in a specified path, not recursive
; Syntax:           _FileListToArrayRecursiveBrief1a($s_PathF, ByRef $s_FileStringF, $s_FilterF) ;quick as not recursive
; Parameter(s):     $s_PathF = Path to generate filelist for
;                   $s_FileStringF = The string for lists all files and folders in a specified path
;                   $s_FilterF = The filter to use. Search the Autoit3 manual for the word "WildCards" For details
;                   $sExcludeF= The Exclude filter to use.  "WildCards" For details
; Requirement(s):   None
; Return Value(s):  On Success - Returns an array containing the list of files and folders in the specified path
;                        On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
;                       @Error=1 Path not found or invalid
;                       @Error=2 Invalid $s_Filter
;                 @Error=4 No File(s) Found
;
; Author(s):        randallc; modified from SolidSnake, SmoKe_N, GEOsoft and big_daddy
;===============================================================================
Func _FileListToArrayRecursiveBrief1a($sPathF, ByRef $sFileStringF, $sFilterF, $sExcludeF = "")
    Local $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sFileF
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $sExcludeF == "" Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            $sFileStringF &= $sPathF & "\" & $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter [remo]
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then ExitLoop

            If Not StringRegExp($sFileF, $sExcludeF) Then $sFileStringF &= $sPathF & "\" & $sFileF & "*" ;this writes the filename to the delimited string with * as delimiter [remo]
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRecursiveBrief1a
Func _ArrayToString1(Const ByRef $AvArray, $sDelim = "|", $iStart = 0, $iEnd = 0)
    If Not IsArray($AvArray) Then Return SetError(1, 0, "")

    Local $sResult, $iUBound = UBound($AvArray) - 1

    ; Bounds checking
    If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound
    If $iStart < 0 Then $iStart = 0
    If $iStart > $iEnd Then Return SetError(2, 0, "")

    ; Combine
    For $i = $iStart To $iEnd
        $sResult &= $AvArray[$i] & $sDelim
    Next

    Return StringTrimRight($sResult, StringLen($sDelim))
EndFunc   ;==>_ArrayToString1
Func _ArrayInsert1(ByRef $AvArray, $iElement, $vValue = "")
    If Not IsArray($AvArray) Then Return SetError(1, 0, 0)

    ; Add 1 to the array
    Local $iUBound = UBound($AvArray) + 1
    ReDim $AvArray[$iUBound]

    ; Move all entries over til the specified element
    For $i = $iUBound - 1 To $iElement + 1 Step -1
        $AvArray[$i] = $AvArray[$i - 1]
    Next

    ; Add the value in the specified element
    $AvArray[$iElement] = $vValue
    Return $iUBound
EndFunc   ;==>_ArrayInsert1

Share this post


Link to post
Share on other sites

But you have steered me into the right direction as to how to get this to work :]

Many thanks Varian!

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