johnmcloud Posted May 25, 2012 Share Posted May 25, 2012 (edited) Hi guys,I'm usign by a bit of time, very useful, I can include/exclude file extensions/folder or select subfolder, and many other. I have this situation now:I want to select example .txt files but i want to exlude the word(s) "time" and "sea" from the filenameExample of the basic array:C:TestMoon.txt C:TestEarth.txt C:TestEarth_is_my_time.txt C:TestSea_on_the_moon.txtResult without the word(s) "time" and "sea" will be:C:TestMoon.txt C:TestEarth.txtIn the same way, example i will only include the word(s) "time" and "sea", the result will be:C:TestEarth_is_my_time.txt C:TestSea_on_the_moon.txtI don't know if this can be do directy on the array, anyway i can save the array on a .txt and then include/remove the word(s). I'll create a GUI for this, but i don't have problem with the gui creation.Some advice?Thanks Edited May 25, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
someone Posted May 25, 2012 Share Posted May 25, 2012 You can definitely accomplish what you are trying to do, this is how I would do it, (code is written on the fly but you will get the idea) For $i = UBound($array) - 1 to 1 Step -1 If StringInStr($array[$i], "time") Then _ArrayDelete($array, $i) EndIf If StringInStr($array[$i], "sea") Then _ArrayDelete($array, $i) EndIf Next _ArrayDisplay($array) Code could be optimized but you will get the idea. Step through the array BACKWARDS, so when you delete an element you don't have to worry about adjusting the amount of times the loop runs (change it to going forwards and you'll see what I mean). While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2012 Moderators Share Posted May 25, 2012 (edited) johnmcloud, The UDF will do it directly - just use the various parameters to define the files you want to include/exclude. This script works as you require when I use your posted filenames: #include <array.au3> #include <recfilelisttoarray.au3> ; Exclude "time" and "sea" $aArray = _RecFileListToArray("Your_Path", "*.txt", 1, 0, 0, 1, "*time*.txt;*sea*.txt") _ArrayDisplay($aArray) ; Only show "time" and "sea" $aArray = _RecFileListToArray("Your_Path", "*time*.txt;*sea*.txt", 1) _ArrayDisplay($aArray) M23 Edited May 25, 2012 by Melba23 Wrong button too soon! 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
johnmcloud Posted May 25, 2012 Author Share Posted May 25, 2012 Thanks Melba, i'll check it out Link to comment Share on other sites More sharing options...
johnmcloud Posted May 25, 2012 Author Share Posted May 25, 2012 (edited) Melba i have problem with "Include only..." For "Exclude" i have make this: $List = _RecFileListToArray($Folder, $FileType, 1, $SubFolder, 0, 2, GUICtrlRead($Input), "") And work. For "include only" this not work: $List = _RecFileListToArray($Folder, GUICtrlRead($Input), 1, $SubFolder, 0, 2, "", "") Give me error for the array. Where i need to add the $SubFolder variable and have the full path? I have the same parameter of "Exclude", i don't know where i'm doing wrong. Thanks Edited May 25, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2012 Moderators Share Posted May 25, 2012 johnmcloud,How about some explanation of the folder structure you are trying to parse and the sort of things you expect to find in the $Input control? And you are using a variable $SubFolder where I would expect to see an integer defining the type of recursion you want the UDF to use - what is this variable? I am very willing to help, but I need some information to work on! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now