Sign in to follow this  
Followers 0
johnmcloud

[SOLVED] _FileListToArray - Exclude extension

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



johnmcloud,

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

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

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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


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

#5 ·  Posted (edited)

$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

Share this post


Link to post
Share on other sites

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


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

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

johnmcloud,

Glad I could help. :)

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

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

  • Similar Content

    • Mag91
      By Mag91
      Hey Everybody,
      as you know im on a very low autoit-level.
      My question is: How can i read all PDFs from a Folder wich is open and copy them to a Folder on a Desktop.
       
      The Folder wich contains the PDFs is variable Z:\Projektls\"*"*"*EVERYTIME ANOTHER ENDING"*"*"*"*"
      There can be 1 PDF or even 15 PDFs.
      i tried it with _FileListToArray and _FileCopy but i Need some help to understand this language
       
      THANKS!
       
    • galan2015
      By galan2015
      Hello, i have question. How put data from _FileListToArray to Combo ?
      I want fill combo with names of files from folder.
    • AutID
      By AutID
      This is more tricky than I thought it would be. I have been searching for some time now and can't seem to find an answer.
      To find the IE history manually I go to "C:UsersuserAppDataLocalMicrosoftWindowsHistory" and from there I select the subfolder(Today, Yesterday etc...) and check the files in it.
      So following this logic I came up with this which should normally work but it doesn't.

      #include <File.au3> #include <Array.au3> Local $File = RegRead ( "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "History" ) ;ConsoleWrite($File & @LF) Local $hSearch = _FileListToArray($File, Default, Default, True) _ArrayDisplay($hSearch) It returns some other files besides the Today, Yesterday folders.
      I assume this happens because they are not actually folders however since FileListToArray second parameter is set to default, which means all files if I understand correctly, then it should also return the paths of theToday folder.
      Anyone any ideas on this?
    • Alexxander
      By Alexxander
      Hi 
      I'am trying to list files from folder sorted by name (same as the picture)

      i tried this code
      #include <File.au3> $arr = _FileListToArray("D:\2") _ArrayDisplay($arr) i am getting this result
       

      Any one could explain why it is putting 10-1 before 8-1 ?
      how can i make Autoit view file same as windows explorer ?
    • Silverlode
      By Silverlode
      Hi everyone,
      I've got a bit of code that gets the file name of a zip file in a particular directory and tried to unzip it.  _FileListToArray should create an array and define $aArray[1] as the first file returned by the search.  But when I try to use $aArray[1] for anything, I get the error: "==> Array variable has incorrect number of subscripts or subscript dimension range exceeded."
      Any thoughts?
      If $osbit = "32" Then Local $aFileList = _FileListToArray($extract_dir, "*win32*") _ExtractZip($extract_dir & $aArray[1], $extract_dir) ElseIf $osbit = "64" Then Local $aFileList = _FileListToArray($extract_dir, "*amd*") _ExtractZip($extract_dir & $aArray[1], $extract_dir) EndIf Thanks.