Jump to content

[SOLVED] _FileListToArray - Exclude extension


Recommended Posts

Hi guys,

with help of M23 now i have this script:

$Path = GUICtrlRead($FolderInput)
$Pre = @TempDir & "\Test.exe"
$Command = "-e -p"
$Folders= _FileListToArray($Path, '*', 1)
$Folders[0] = "@echo off" & @CRLF

$fFlag = ""
AdlibRegister("Update",333)
For $i = 1 To UBound($Folders) - 1
If RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & $Password & " " & '"' & $Path & "\" & $Folders[$i] & '"', @TempDir, @SW_HIDE) = 0 Then
ConsoleWrite("Information - Success")
    Else
        $fFlag &= $i & "|"
    EndIf
    ConsoleWrite("Information - Fail")
  
Next
If $fFlag = "" Then
If GUICtrlRead($FolderCheckboxCrypt) = $GUI_CHECKED Then
  Func()
EndIf
FileDelete(@TempDir & "\Test.txt")
MsgBox(0, "Information","OK")
Else
    $aFailed = StringSplit($fFlag, "|")
    $sMsg = "Error:" & @CRLF & @CRLF
    For $i = 1 To $aFailed[0] - 1
        $sMsg &= $Folders[$aFailed[$i]] & @CRLF
    Next
FileDelete(@TempDir & "\Test.exe")
    MsgBox(16, "Error", $sMsg)
EndIf
AdlibUnRegister("Update")
WinSetTitle($GUI,"","Test name")
EndFunc

From option of _FileListToArray i see you can select exstension to process by array, ad example *.txt

But i don' find something to exclude an extension from array.

Someone can resolve this doubt?

Thanks to all for support, i'll grateful to this forum :)

Edited by johnmcloud
Link to comment
Share on other sites

  • Moderators

johnmcloud,

Look at the RecFileListToArray UDF in my sig - it allows you to include/exclude multiple options. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Thanks Melba, but somethig is wrong becouse file will be not processed.

I have change only this part with helper ( i have test it and esclude the extension )

#include <RecFileListToArray.au3>

$Folders= _RecFileListToArray($Path, "*.*", 1, 0, 0, 2, "*.txt", "")

I don't have error, but the file will be not processed

Edited by johnmcloud
Link to comment
Share on other sites

  • Moderators

johnmcloud,

the file will be not processed

I do not understand what you mean. When I run your snippet I get the all the files from the folder (less the excluded ones) in the returned array. :)

And why do you call the array $Folders when you are asking for files only to be returned? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

$Path = GUICtrlRead($FolderInput)
$Pre = @TempDir & "Test.exe"
$Command = "-e -p"
$Folders= _RecFileListToArray($Path, "*.*", 1, 0, 0, 2, "*.txt", "")
$Folders[0] = "@echo off" & @CRLF
$fFlag = ""

AdlibRegister("Update",333)
For $i = 1 To UBound($Folders) - 1
If RunWait(@ComSpec & " /c " & $pre & " " & $command & " " & $Password & " " & '"' & $Path & "" & $Folders[$i] & '"', @TempDir, @SW_HIDE) = 0 Then
ConsoleWrite("Information - Success")
    Else
        $fFlag &= $i & "|"
    EndIf
    ConsoleWrite("Information - Fail")

Next
If $fFlag = "" Then
If GUICtrlRead($FolderCheckboxCrypt) = $GUI_CHECKED Then
  Func()
EndIf
FileDelete(@TempDir & "Test.txt")
MsgBox(0, "Information","OK")
Else
    $aFailed = StringSplit($fFlag, "|")
    $sMsg = "Error:" & @CRLF & @CRLF
    For $i = 1 To $aFailed[0] - 1
        $sMsg &= $Folders[$aFailed[$i]] & @CRLF
    Next
FileDelete(@TempDir & "Test.exe")
    MsgBox(16, "Error", $sMsg)
EndIf
AdlibUnRegister("Update")
WinSetTitle($GUI,"","Test name")
EndFunc

Is the same code, with the _FileListToArray($Path, '*', 1) work fine but process all file, with _RecFileListToArray don't process any file ( and give me msgbox "OK" )

For the name $folders... it's copy past code, in the same script it process folder and i forget to reneame :)

Edited by johnmcloud
Link to comment
Share on other sites

  • Moderators

johnmcloud,

Use _ArrayDisplay and see what difference there is between the arrays returned by _FileListToArray and _RecFileListToArray. :)

Using $iReturnPath = 2 you are getting the "Full path" for the files returned by _RecFileListToArray. So I believe you will no longer need to add the path again in your RunWait line. Or you could use $iReturnPath = 1 to get the "Relative path" as returned by _FileListToArray. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

johnmcloud,

Use _ArrayDisplay and see what difference there is between the arrays returned by _FileListToArray and _RecFileListToArray

Yeah, there is a difference of path, you have right, i'm too noob :)

I have change this:

$Folders= _RecFileListToArray($Path, "*.*", 0, 0, 0, 1, "*.txt", "")

It processed two time the path in cmd, i'll set the relative now.

Thanks for support Melba and for UDF

Edited by johnmcloud
Link to comment
Share on other sites

  • Moderators

johnmcloud,

Glad I could help. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

×
×
  • Create New...