Chimaera Posted May 8, 2015 Share Posted May 8, 2015 Im working on a script to find files in a download folder that belong together like a set if you willexpandcollapse popup#include <APIConstants.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WinAPIEx.au3> #include <File.au3> ; For Pathsplit ; --------------------------------- Global $g_aDropFiles[0] ; Internal array, DO NOT USE directly. Instead call GetDropFiles() & IsValidDrop() ; --------------------------------- $sArchiveExt = '.par2|.par3' $sArchiveExt &= '.rar|.001|.zip|.7z' $sArchiveExt &= '.nfo|.sfv|.nzb' $sArchiveExt &= '.r00|.r01' Local $ExtTypes = StringSplit($sArchiveExt, "|") ; Support for upto 300 deep rar archives StartGui() Func StartGui() Local $hGUI = GUICreate('', 500, 500, -1, -1, -1, $WS_EX_ACCEPTFILES) Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_DROPFILES, $MSGFLT_ALLOW) ; IMPORTANT: If the system is using limited access rights If IsAdmin() Then _WinAPI_ChangeWindowMessageFilterEx($hGUI, $WM_COPYGLOBALDATA, $MSGFLT_ALLOW) ; IMPORTANT: If the system is using limited access rights ; --------------------------------- GUICtrlCreateLabel('', 0, 0, 500, 500) ; Create a label that is transparent which will accept 'drop' events. GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUIRegisterMsg($WM_DROPFILES, 'WM_DROPFILES') GUISetState(@SW_SHOW, $hGUI) Local $aDropped = 0 ; --------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_DROPPED $aDropped = GetDropFiles() ; This always returns a valid array regardless of an error If IsValidDrop() Then ; Was a valid drop? _ArraySort($aDropped); Sort the array so the first file is at the top _ArrayDisplay($aDropped) ; <<<<<<<<<< error checking $FirstFile = $aDropped[1]; Select only the first file for the name $FileSplit = _PathSplit($FirstFile, $sDrive, $sDir, $sFilename, $sExtension) ; split the name from the path $sPath = $sDrive & $sDir ConsoleWrite('Path = ' & $sPath & @CRLF) ConsoleWrite('Drive = ' & $sDrive & @CRLF & 'Dir = ' & $sDir & @CRLF & 'Filename = ' & $sFilename & @CRLF & 'Extension = ' & $sExtension & @CRLF) ; <<<<<<<<<< error checking ;---------------------------------------- For $i = 1 To $ExtTypes[0] Local $FindFiles = _FileListToArrayRec($sPath, '*' & StringTrimLeft($sFilename, 7) & '*', 1, 0) _ArrayDisplay($FindFiles, "Files") If IsArray($FindFiles) Then For $i = 1 To $FindFiles[0] FileMove($sPath & $FindFiles[$i], $sPath & $sFilename & "\", 9) Sleep(100) Next EndIf Next ;---------------------------------------- Else MsgBox(64, 'File Error', 'Unknown Archive File Type') EndIf ConsoleWrite(@CRLF) ; Empty line EndSwitch WEnd GUIDelete($hGUI) ; Clean up the resources EndFunc ;==>StartGui ; Get the dropped list of files. NOTE: Destroys the global varibale on return Func GetDropFiles() Local Const $aEmpty[1] = [0] ; Empty array Local $aReturn = $g_aDropFiles $g_aDropFiles = $aEmpty ; Destroy the global variable with the empty array Return $aReturn EndFunc ;==>GetDropFiles ; Use to determine if the drop was valid Func IsValidDrop() Return UBound($g_aDropFiles) > 0 EndFunc ;==>IsValidDrop Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $lParam If $iMsg = $WM_DROPFILES Then $g_aDropFiles = _WinAPI_DragQueryFileEx($wParam) If Not UBound($g_aDropFiles) Then Local Const $aError[1] = [0] ; Empty array $g_aDropFiles = $aError ; Set with the empty array EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_DROPFILESThe problem is thisFor $i = 1 To $ExtTypes[0] ; Find if there is more than one set Local $FindFiles = _FileListToArrayRec($sPath, '*' & StringTrimLeft($sFilename, 7) & '*', 1, 0) _ArrayDisplay($FindFiles, "Files") If IsArray($FindFiles) Then For $i = 1 To $FindFiles[0] FileMove($sPath & $FindFiles[$i], $sPath & $sFilename & "\", 9) Sleep(100) Next EndIf NextI cant think of any way to do this part StringTrimLeft($sFilename, 7) so that it removes enough of the file ending so that all files will be found because they have the same nameLong Filemame With No Usuable Chars78 is fine but other files in the set maybe different like thisLong Filemame With No Usuable Chars78.vol00+01 just about works but would miss the earlier filetapcla02 can work but 7 chars makes it clash with other files sometimes413529af4de5db32dd88963aaf177729.vol07+8 can be ok as wellk8NXnJs_8ZF8wk6qsoK.part06 works fineReally Long Filename.v1.40.208-TEST for eg would work but would miss this following fileReally Long Filename.v1.40Ive tried different amounts for the trim but i keep finding files that dont work and then it misses themIs there a way to remove enough of the file ending to be able to safely compare the file against other files in the same folder?, maybe the end numbers with the addition of the word vol and/or part maybe?Or a different way to distinguish many files in a folder amongst other files If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 8, 2015 Moderators Share Posted May 8, 2015 Chimaera,Can you please post a representative file list showing which files you want selected and which you want excluded - and which of the files you are using as the _FileListToArrayRec filter template after the _PathSplit operation. That should allow the development of a suitable pattern - I am afraid your description above of the various possibilities is rather confused.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...
guinness Posted May 8, 2015 Share Posted May 8, 2015 To tack onto what @Melba23 said, don't declare variables inside loops, as it's hinders performance. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2015 Moderators Share Posted May 10, 2015 (edited) Chimaera,Based on the file list you PMed me, this function seems to work quite well - if I have correctly guessed the members of each family:expandcollapse popup#include <Array.au3> Global $aList[] = [25, _ "####### 12 v12.0.00800 MultiLingual Genial78.par2", _ "####### 12 v12.0.00800 MultiLingual Genial78.part1.rar", _ "####### 12 v12.0.00800 MultiLingual Genial78.part2.rar", _ "####### 12 v12.0.00800 MultiLingual Genial78.part3.rar", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol00+01.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol01+02.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol03+04.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol07+08.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol15+13.PAR2", _ "~~~~~~~.v.1.40.208-TE.nfo", _ "~~~~~~~.v.1.40.208-TE.r00", _ "~~~~~~~.v.1.40.208-TE.r01", _ "~~~~~~~.v.1.40.208-TE.r02", _ "~~~~~~~.v.1.40.208-TE.r03", _ "~~~~~~~.v.1.40.208-TE.r04", _ "~~~~~~~.v.1.40.208-TE.r05", _ "~~~~~~~.v.1.40.208-TE.r06", _ "~~~~~~~.v.1.40.208-TE.rar", _ "~~~~~~~.v.1.40.nzb", _ "~~~~~~~.v.1.40.par2", _ "~~~~~~~.v.1.40.sfv", _ "~~~~~~~.v.1.40.vol00+1.PAR2", _ "~~~~~~~.v.1.40.vol01+2.PAR2", _ "~~~~~~~.v.1.40.vol03+4.PAR2", _ "~~~~~~~.v.1.40.vol07+6.PAR2"] ; Loop through the list to test each element individually For $i = 1 To $aList[0] _Get_Family($aList[$i]) Next Func _Get_Family($sDropped) Local $sTest, $iCount, $iMax_Count = 0, $iIndex, $aFamily ; Start trimming characters from right of the passed string For $j = 1 To StringLen($sDropped) - 1 $sTest = StringTrimRight($sDropped, $j) $iCount = 0 ; Check match for the trimmed string againt every element of the list For $k = 1 To $aList[0] If StringRegExp($aList[$k], "^" & $sTest & ".*$") Then ; Increase count if matched $iCount += 1 EndIf Next ; If count is higher then cuurent max then store data If $iCount > $iMax_Count Then $iMax_Count = $iCount $iIndex = $j EndIf Next ; We now know the longest string that gives the max number of matches ; Now extract these matches from the array by matching the trimmed string If $iMax_Count Then ; Array to hold the matches and the index to fill Local $aFamily[$iCount + 1] = [$iMax_Count], $iInsert = 1 ; Create the trimmed string $sBase = StringTrimRight($sDropped, $iIndex) ConsoleWrite($sBase & @CRLF) ; loop through the array For $k = 1 To $aList[0] ; If a match If StringRegExp($aList[$k], "^" & $sBase & ".*$") Then ; Add to the array $aFamily[$iInsert] = $aList[$k] ; And increase the index $iInsert += 1 EndIf Next ; And these are the matches for each element _ArrayDisplay($aFamily, $aList[$i], Default, 8) EndIf EndFuncIs that what you wanted? Can a RegEx guru do it better?M23 Edited May 11, 2015 by Melba23  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...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 (edited) Thats very close it seems to find the elements  but it finds both downloads, its only supposed to find the one that i drop on the gui and ignore any others unless i drop them on the gui.So i give the gui one file from a set and it retrieves all the files from that set  which i then move elsewhereMany thanks EDIT now ive tried to add to main script with the drop and i cant seem to get it to work, leave it with me and ill see what i can do Edited May 10, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2015 Moderators Share Posted May 10, 2015 (edited) Chimaera,to find files in a download folder that belong togetherwhich is what I thought the function did?  When you pass it a "#######" file it finds all the other files of the "#######" family but none of the "~~~~~~~" ones - and vice versa. If this is not what you want, then please let me know for each of the files in that list which other files it is supposed to match, as we obviously have different ideas of "family".M23 Edited May 11, 2015 by Melba23  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...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 i added your eg to the real list and gave it 1 nero file and it returned both nero family and opencloner familyIf i give it nero for eg it should only return nero filesOne small question $FindFiles = _FileListToArrayRec($sPath, '*' & StringTrimRight($sFilename, 7) & '*', 1, 0) _ArrayDisplay($FindFiles, ".Rar Files")All i supplied here was a the name of one file which was the drop file using $sFilenameFor $i = 1 To $aList[0] _Get_Family($aList[$i]) NextIve tried modding this but it expects an array which i dont have as i only have a single filename and i dont know the list at this point any pointers plz.Itried like this but im just getting array errors all over the place$FindFiles = _Get_Family($sFilename) If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2015 Moderators Share Posted May 10, 2015 Chimaera,i added your eg to the real list and gave it 1 nero file and it returned both nero family and opencloner familyThen let me have a copy of the real list.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...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 The real list is the same filenames you have but in files rather than an array If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2015 Moderators Share Posted May 10, 2015 (edited) Chimaera,I have rewritten the code to make the function self contained so you can use it directly in your script. Does this still return all the files for each elements?expandcollapse popup#include <Array.au3> #include <MsgBoxConstants.au3> Global $aFileList[] = [25, _ "####### 12 v12.0.00800 MultiLingual Genial78.par2", _ "####### 12 v12.0.00800 MultiLingual Genial78.part1.rar", _ "####### 12 v12.0.00800 MultiLingual Genial78.part2.rar", _ "####### 12 v12.0.00800 MultiLingual Genial78.part3.rar", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol00+01.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol01+02.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol03+04.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol07+08.PAR2", _ "####### 12 v12.0.00800 MultiLingual Genial78.vol15+13.PAR2", _ "~~~~~~~.v.1.40.208-TE.nfo", _ "~~~~~~~.v.1.40.208-TE.r00", _ "~~~~~~~.v.1.40.208-TE.r01", _ "~~~~~~~.v.1.40.208-TE.r02", _ "~~~~~~~.v.1.40.208-TE.r03", _ "~~~~~~~.v.1.40.208-TE.r04", _ "~~~~~~~.v.1.40.208-TE.r05", _ "~~~~~~~.v.1.40.208-TE.r06", _ "~~~~~~~.v.1.40.208-TE.rar", _ "~~~~~~~.v.1.40.nzb", _ "~~~~~~~.v.1.40.par2", _ "~~~~~~~.v.1.40.sfv", _ "~~~~~~~.v.1.40.vol00+1.PAR2", _ "~~~~~~~.v.1.40.vol01+2.PAR2", _ "~~~~~~~.v.1.40.vol03+4.PAR2", _ "~~~~~~~.v.1.40.vol07+6.PAR2"] ; Loop through the list to test each element individually For $i = 1 To $aFileList[0] MsgBox($MB_SYSTEMMODAL, "Return from:", $aFileList[$i]) $aFamily = _Get_Family($aFileList[$i], $aFileList) _ArrayDisplay($aFamily, "Family", Default, 8) Next Func _Get_Family($sDropped, $aList) Local $sTest, $iCount, $iMax_Count = 0, $iIndex, $aFamily ; Start trimming characters from right of the passed string For $j = 1 To StringLen($sDropped) - 1 $sTest = StringTrimRight($sDropped, $j) $iCount = 0 ; Check match for the trimmed string againt every element of the list For $k = 1 To $aList[0] If StringRegExp($aList[$k], "^" & $sTest & ".*$") Then ; Increase count if matched $iCount += 1 EndIf Next ; If count is higher then cuurent max then store data If $iCount > $iMax_Count Then $iMax_Count = $iCount $iIndex = $j EndIf Next ; We now know the longest string that gives the max number of matches ; Now extract these matches from the array by matching the trimmed string If $iMax_Count Then ; Array to hold the matches and the index to fill Local $aFamily[$iCount + 1] = [$iMax_Count], $iInsert = 1 ; Create the trimmed string $sBase = StringTrimRight($sDropped, $iIndex) ; loop through the array For $k = 1 To $aList[0] ; If a match If StringRegExp($aList[$k], "^" & $sBase & ".*$") Then ; Add to the array $aFamily[$iInsert] = $aList[$k] ; And increase the index $iInsert += 1 EndIf Next Return $aFamily EndIf EndFuncM23 Edited May 11, 2015 by Melba23  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...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 (edited) Hmm im sorry i dont know if im explaining this correctI drop a single file which gives me this at the check1 J:\# Tailored\# Simple Unpacker\Test Files\## Rar\####### 12 v12.0.00800 Multilingual Genial78.vol01+02.PAR2I then extract the parts from PathSplit which gives me the $sFilename to use for the search of the rest of the files$sPath = J:\# Tailored\# Simple Unpacker\Test Files\## Rar\ $sDrive = J: $sDir = \# Tailored\# Simple Unpacker\Test Files\## Rar\ $sFilename = ####### 12 v12.0.00800 Multilingual Genial78.vol01+02 $sExtension = .PAR2I then check the extension against a pre determined list of acceptable file types, the real one is 700 long$sArchiveExt = '.par2|.par3' $sArchiveExt &= '|.nfo|.sfv|.nzb|.rar' Local $aExtTypes = StringSplit($sArchiveExt, "|")And cycle through the listLocal $FindFiles = 0 For $i = 1 To $aExtTypes[0]And Then im trying to get a list from the only source i have which is the variable below$sExtensionFrom your exampleFor $i = 1 To $aFileList[0] MsgBox($MB_SYSTEMMODAL, "Return from:", $aFileList[$i]) $aFamily = _Get_Family($aFileList[$i], $aFileList) _ArrayDisplay($aFamily, "Family", Default, 8) NextWhere do i get the data to fill all that when i only have 1 filename?Sorry for not understanding but this is making no sense to me at all  as i have no array or anything to useIm just trying to find all matching files to this filename####### 12 v12.0.00800 Multilingual Genial78.vol01+02 Edited May 11, 2015 by Melba23 If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
guinness Posted May 10, 2015 Share Posted May 10, 2015 I know M23 is helping, but look at _IsValidType() in my signature for checking if a filepath matches a "list" of extensions.  Then you have no loops...loops loops looooops! UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 @guinness ok thx i have implemented it higher up so the path split doesnt happen if its FALSE If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2015 Moderators Share Posted May 10, 2015 Chimaera,this is making no sense to me at allI could say the same thing. Let me try and explain what I understand you to want.You have a single dropped file which you split to get a filename and extension You compare the extension to a very long list of possible extensions and if the extension is "valid" you then want to find all files that are of a similar "family" within a given folder. The function I posted will find all members of a "family" within a folder the contents of which have been placed into an array using _FileListToArray. The parameters of the function are the dropped filename (less the path) and the list of files in the folder.Here is a short working example of how I see the process:expandcollapse popup#include <File.au3> #include <MsgBoxConstants.au3> Global $sAutoIt_Path = StringRegExpReplace(@AutoItExe, "(^.*\\)(.*)", "\1") ; Simulate dropped filename $sDropped = "J:\FilePath\AutoIt3.exe" ; Simulate list of valid extensions $sArchiveExt = "exe|com|bat" Local $aExtTypes = StringSplit($sArchiveExt, "|") ; Split dropped filename Local $sDrive, $sDir, $sFileName, $sExtension _PathSplit($sDropped, $sDrive, $sDir, $sFileName, $sExtension) ConsoleWrite($sExtension & @CRLF) ; Check if valid extension (after removing .) If _ArraySearch($aExtTypes, StringTrimLeft($sExtension, 1)) = -1 Then MsgBox($MB_SYSTEMMODAL, "Error", "Not valid extension") Exit EndIf ; Get a list of the files of the correct type in the folder (simulated by the AutoIt root folder) $aFileList = _FileListToArray($sAutoIt_Path, "*" & $sExtension, $FLTA_FILES) _ArrayDisplay($aFileList, "All .exe files", Default, 8) ; And now find all the files which could belong to the same family using the function I posted earlier $aFamily = _Get_Family($sFileName & $sExtension, $aFileList) ; I get everything bar "Unintall.exe" as the rest belong to the "Au*.exe" family _ArrayDisplay($aFamily, "Family files", Default, 8) Func _Get_Family($sDropped, $aList) Local $sTest, $iCount, $iMax_Count = 0, $iIndex, $aFamily For $j = 1 To StringLen($sDropped) - 1 $sTest = StringTrimRight($sDropped, $j) $iCount = 0 For $k = 1 To $aList[0] If StringRegExp($aList[$k], "^" & $sTest & ".*$") Then $iCount += 1 EndIf Next If $iCount > $iMax_Count Then $iMax_Count = $iCount $iIndex = $j EndIf Next If $iMax_Count Then Local $aFamily[$iCount + 1] = [$iMax_Count], $iInsert = 1 $sBase = StringTrimRight($sDropped, $iIndex) For $k = 1 To $aList[0] If StringRegExp($aList[$k], "^" & $sBase & ".*$") Then $aFamily[$iInsert] = $aList[$k] $iInsert += 1 EndIf Next Return $aFamily EndIf EndFuncIs that anywhere near close to what you are trying to do?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...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 (edited) Damn so close i add a spoof file called this####### 12 v12.0.00800 Multilingual Genial78.part3.x00As it clearly wont pass the Valid listand amended my version like thisLocal $aFindFiles = 0, $aValidFiles = 0 ; Get a list of the files of the correct type in the folder (simulated by the AutoIt root folder) $aFileList = _FileListToArray( $sFolderPath, "*", $FLTA_FILES) _ArrayDisplay($aFileList, "All .exe files", Default, 8) ; And now find all the files which could belong to the same family using the function I posted earlier $aFamily = _Get_Family($sFileName, $aFileList) _ArrayDisplay($aFamily, "Family files", Default, 8) For $i = 1 To $aFamily[0] $sValidCheck = _IsValidFileType( $aFamily[$i], $sArchiveExt) If $sValidCheck = True Then ;~ ConsoleWrite($sValidCheck &@CRLF) $aValidFiles = _ArrayAdd( $aFindFiles, $aFileList[$i]) EndIf Next _ArrayDisplay($aValidFiles, "Valid files", Default, 8)But it keeps failing the last array, where have i gone wrong?The earlier two array checks work fine all i need to do is exclude the files that are not on the approved list Edited May 11, 2015 by Melba23 If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 10, 2015 Moderators Share Posted May 10, 2015 Chimaera,Does this meet the bill?expandcollapse popup#include <File.au3> #include <MsgBoxConstants.au3> Global $sAutoIt_Path = StringRegExpReplace(@AutoItExe, "(^.*\\)(.*)", "\1") ; Simulate dropped filename $sDropped = "J:\FilePath\AutoIt3.exe" ; Simulate list of valid extensions $sArchiveExt = "exe|com|dat" Local $aExtTypes = StringSplit($sArchiveExt, "|") ; Split dropped filename Local $sDrive, $sDir, $sFileName, $sExtension _PathSplit($sDropped, $sDrive, $sDir, $sFileName, $sExtension) ; Check if valid extension If _IsValidFileType($sExtension) = -1 Then MsgBox($MB_SYSTEMMODAL, "Error", "Not valid extension") Exit EndIf ; Get a list of the files in the AutoIt root folder $aFileList = _FileListToArray($sAutoIt_Path, "*", $FLTA_FILES) _ArrayDisplay($aFileList, "All .exe files", Default, 8) ; Noww find all the files which could belong to the same family using the function I posted earlier $aFamily = _Get_Family($sFileName, $aFileList) ; And finally check which of these have valid extesions For $i = UBound($aFamily) - 1 To 1 Step -1 If _IsValidFileType(StringRegExpReplace($aFamily[$i], "^.*\.", ".$1")) = -1 Then _ArrayDelete($aFamily, $i) $aFamily[0] -= 1 EndIf Next _ArrayDisplay($aFamily, "Family files", Default, 8) Func _Get_Family($sDropped, $aList) Local $sTest, $iCount, $iMax_Count = 0, $iIndex, $aFamily For $j = 1 To StringLen($sDropped) - 1 $sTest = StringTrimRight($sDropped, $j) $iCount = 0 For $k = 1 To $aList[0] If StringRegExp($aList[$k], "^" & $sTest & ".*$") Then $iCount += 1 EndIf Next If $iCount > $iMax_Count Then $iMax_Count = $iCount $iIndex = $j EndIf Next If $iMax_Count Then Local $aFamily[$iCount + 1] = [$iMax_Count], $iInsert = 1 $sBase = StringTrimRight($sDropped, $iIndex) For $k = 1 To $aList[0] If StringRegExp($aList[$k], "^" & $sBase & ".*$") Then $aFamily[$iInsert] = $aList[$k] $iInsert += 1 EndIf Next Return $aFamily EndIf EndFunc Func _IsValidFileType($sExt) Return _ArraySearch($aExtTypes, StringTrimLeft($sExt, 1)) EndFuncM23  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...
Chimaera Posted May 10, 2015 Author Share Posted May 10, 2015 Many thanks for the help i shall go away and digest the info If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Chimaera Posted May 11, 2015 Author Share Posted May 11, 2015 Done some testing today at work, seems to be fine for the most partBut it fails on thisIt can find all the files and determine the file_id.diz is not part of the setBut it cant tell any difference between the remaining files If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 11, 2015 Moderators Share Posted May 11, 2015 Chimaera,I imagine that is because other than file_id.diz all the other files begin with "t". I suggest changing the loop variable in the _Get_Family function so that it stops when there are still a few letters left in the string - try this:For $j = 1 To StringLen($sDropped) - 5 ; Rather than 1Now the function will not shorten the string below that figure when trying to match and so should not match every "t*" file in the array.It might be worth trying to develop an algorithm which could automatically detect when to stop the shortening. I will have a think about how this might be done - can you let me have a representative sample of the sort of family names you want to detect so I can see what sort of names we are having to distinguish and how we might develop some suitable code.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...
Chimaera Posted May 11, 2015 Author Share Posted May 11, 2015 (edited) thats working again now thxSo does it work by shortening a letter each time till it matches?The family names could be tons of possibles, ill try and throw one of each type i can find in a folder and show you an image of it, may take a while to collect.Maybe it need a comparison against the name file as we know the name of the dropped file, maybe its possible to build a test against that filename one letter at a time Edited May 11, 2015 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() 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