Jump to content

directory display - wildcards problem


Recommended Posts

i want to list the directories using a filter with $FolderList=_FileListToArray("d:\test folder", ,2) and i cant find the wildcards in help file

i want to list the directories only with numbers and "_" character (no letters)

how do i do that?

tnx

Edited by carabusu
Link to comment
Share on other sites

Check out FileFindFirstFile() and FileFindNextFile(). You can use wildcards there easy enough. Or, you could check out StringRegExp() maybe.

HI,

or just delete the unwanted afterwards. :-)

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

with FileFindFirstFile it works only ? and * and i need to find directories like 3_5_0_234 or 3_5_0_335 and so on..

ive try to delete them but it wont work

$FolderList=_FileListToArray("d:\test folder","*" ,2)

For $j = 1 To $FolderList[0]

if StringLen($FolderList[$j])==9 then _ArrayDelete($folderlist,$j) ;only folders with 9 characters

Next

error:

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

if StringLen($FolderList[$j])==9 then

if StringLen(^ ERROR

Link to comment
Share on other sites

Hi,

try this:

#Include <File.au3>
#Include <Array.au3>

$a = deleteFoldersWithLetters('c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests')
If IsArray($a) Then
    _ArrayDisplay($a, 'Found')
Else
    MsgBox(0, "", $a)
EndIf

Func deleteFoldersWithLetters($path)
    Local $FolderList = _FileListToArray($path, '*.', 2)
    If @error = 1 Then Return -1
    Local $copy = $FolderList
    For $i = 1 To UBound($FolderList) - 1
        ;If StringRegExp($FolderList[$i], '[\d_]+\b', 0) = 0 Then _ArrayDelete($copy, $i)
        If (StringRegExp($FolderList[$i], '[\d_]+\b', 0) = 0 And StringLen($FolderList[$i]) = 9) Then _ArrayDelete($copy, $i) ; only length 9
    Next
    $copy[0] = UBound($copy)
    Return $copy
EndFunc   ;==>deleteFoldersWithLetters

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

its not working

its returning me all the directories

like this its working fine but it adds not leeters directories over all directorie

Local $copy
        For $i = 1 To UBound($FolderList) -1
    ;For $i = 1 To $FolderList[0]
            
        ;   If StringRegExp($FolderList[$i], '[\d_]+\b', 0) = 0 Then _ArrayDelete($copy, $i)
        ;If (StringRegExp($FolderList[$i], '[\d_]+\b', 0) = 0 And StringLen($FolderList[$i]) == 9) Then _ArrayDelete($FolderList, $i) ; only length 9
         If StringLen($FolderList[$i]) == 9 Then _Arrayadd($copy, $folderlist[$i]) ; only length 9
    Next
Edited by carabusu
Link to comment
Share on other sites

ive solved it:

#Include <File.au3>
#Include <Array.au3>

$a = deleteFoldersWithLetters('d:\test folder')
If IsArray($a) Then
    _ArrayDisplay($a, 'Found')
Else
    MsgBox(0, "", $a)
EndIf

Func deleteFoldersWithLetters($path)
    Local $FolderList = _FileListToArray($path, '*.', 2)
    If @error = 1 Then Return -1
    ;Local $copy[0]
    Local $copy[1]
        For $i = 1 To UBound($FolderList) -1
    ;For $i = 1 To $FolderList[0]
            
        ;   If StringRegExp($FolderList[$i], '[\d_]+\b', 0) = 0 Then _ArrayDelete($copy, $i)
        ;If (StringRegExp($FolderList[$i], '[\d_]+\b', 0) = 0 And StringLen($FolderList[$i]) == 9) Then _ArrayDelete($FolderList, $i) ; only length 9
         If StringLen($FolderList[$i]) == 9 Then _Arrayadd($copy, $folderlist[$i]) ; only length 9
    Next
    $copy[0] = UBound($copy)
    Return $copy
EndFunc   ;==>deleteFoldersWithLetters

a big TNX

Edited by carabusu
Link to comment
Share on other sites

Hi,

sorry try this:

#Include <File.au3>
#Include <Array.au3>

$a = deleteFoldersWithLetters('c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests')
If IsArray($a) Then
    _ArrayDisplay($a, 'Found')
Else
    MsgBox(0, "", $a)
EndIf

Func deleteFoldersWithLetters($path)
    Local $FolderList = _FileListToArray($path, '*.', 2)
    If @error = 1 Then Return -1
    Local $copy = $FolderList
    For $i = UBound($FolderList) - 1 To 1 Step - 1
        If StringRegExp($FolderList[$i], '\b[\d_]{9}\b', 0) = 0 Then _ArrayDelete($copy, $i)
    Next
    $copy[0] = UBound($copy) - 1
    Return $copy
EndFunc   ;==>deleteFoldersWithLetters

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...