NDog Posted July 15, 2015 Share Posted July 15, 2015 (edited) I am trying to come up with something to compare similarly named folders and only keep one. If it finds folders with similar names, I want it to find the common name of the folder, strip the trailing name and remove the unneeded folders, only keeping the renamed folder. Also keep any unique folders.This is all I have so far. I am not sure what I need to do to compare the folder names...Please help, thanks!#include <Array.au3> #include <File.au3> $backup_dir = @TempDir & "\drivers" $array_dirlist = _FileListToArray($backup_dir, "*",2) ; only folders _ArrayDisplay($array_dirlist,"list of folders") For $i = 1 To UBound($array_dirlist) - 1 ConsoleWrite($array_dirlist[$i]&@CRLF) NextIntel(R) 7 SeriesC216 Chipset Family PCI Express Root Port 1 - 1E10 Intel(R) 7 SeriesC216 Chipset Family PCI Express Root Port 5 - 1E18 Intel(R) 7 SeriesC216 Chipset Family SATA AHCI Controller Intel(R) 7 SeriesC216 Chipset Family SMBus Host Controller - 1E22 Intel(R) 7 SeriesC216 Chipset Family Universal Serial Bus (USB) Controller - 1E1 Intel(R) 7 SeriesC216 Chipset Family USB Enhanced Host Controller - 1E26 Intel(R) 7 SeriesC216 Chipset Family USB Enhanced Host Controller - 1E2D NVIDIA High Definition Audio NVIDIA High Definition Audio#1 NVIDIA High Definition Audio#2 NVIDIA High Definition Audio#3 Realtek High Definition Audio VMware Virtual Ethernet Adapter for VMnet1 VMware Virtual Ethernet Adapter for VMnet8 Xeon(R) processor E3-1200 v23rd Gen Core processor DRAM Controller - 0150 Xeon(R) processor E3-1200 v23rd Gen Core processor PCI Express Root Port - 0151 Edited July 15, 2015 by NDog Add image for clarity Link to comment Share on other sites More sharing options...
RaiNote Posted July 15, 2015 Share Posted July 15, 2015 You could compare similar folders with the Functions of String.au3I can't help more because I am really bad working with strings. C++/AutoIt/OpenGL Easy Coder I will be Kind to you and try to help you till what you want isn't against the Forum Rules~ Link to comment Share on other sites More sharing options...
guinness Posted July 15, 2015 Share Posted July 15, 2015 I can't help more because I am really bad working with strings.Strings are fundamental to EVERY high-level language I know, so if you can't grasp them now, then there is little chance for you to create anything wonderful!@NDogThere is a tool by Yashied for syncing files. Perhaps check that out, unless you like a challenge? 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...
RaiNote Posted July 15, 2015 Share Posted July 15, 2015 Strings are fundamental to EVERY high-level language I know, so if you can't grasp them now, then there is little chance for you to create anything wonderful! I know I know because that i am learning to work with it constantly . C++/AutoIt/OpenGL Easy Coder I will be Kind to you and try to help you till what you want isn't against the Forum Rules~ Link to comment Share on other sites More sharing options...
Danyfirex Posted July 15, 2015 Share Posted July 15, 2015 (edited) I think something like this. Updated.expandcollapse popup#include <Array.au3> Local $aFilePaths=["Intel(R) 7 SeriesC216 Chipset Family PCI Express Root Port 1 - 1E10", _ "Intel(R) 7 SeriesC216 Chipset Family PCI Express Root Port 5 - 1E18", _ "Intel(R) 7 SeriesC216 Chipset Family SATA AHCI Controller", _ "Intel(R) 7 SeriesC216 Chipset Family SMBus Host Controller - 1E22", _ "Intel(R) 7 SeriesC216 Chipset Family Universal Serial Bus (USB) Controller - 1E1", _ "Intel(R) 7 SeriesC216 Chipset Family USB Enhanced Host Controller - 1E26", _ "Intel(R) 7 SeriesC216 Chipset Family USB Enhanced Host Controller - 1E2D", _ "NVIDIA High Definition Audio", _ "NVIDIA High Definition Audio#1", _ "NVIDIA High Definition Audio#2", _ "NVIDIA High Definition Audio#3", _ "Realtek High Definition Audio", _ "VMware Virtual Ethernet Adapter for VMnet1", _ "VMware Virtual Ethernet Adapter for VMnet8", _ "Xeon(R) processor E3-1200 v23rd Gen Core processor DRAM Controller - 0150", _ "Xeon(R) processor E3-1200 v23rd Gen Core processor PCI Express Root Port - 0151"] Local $AFind[] = ["Family", "Audio", "VMnet", "Core processor"] _ArrayDisplay($aFilePaths) Local $Exist = False Local $NewFilePaths[0] Local $index = 0 Local $Count=0 For $x = 0 To UBound($AFind) - 1 For $i = 0 To UBound($aFilePaths) - 1 if $index>1 then if not StringInStr($aFilePaths[$i],$NewFilePaths[$index-1]) then $Exist=False endif $Count=StringInStr($aFilePaths[$i], $AFind[$x]) If $Count And $Exist = False Then ReDim $NewFilePaths[UBound($NewFilePaths) + 1] $NewFilePaths[$index] = Stringleft($aFilePaths[$i],$Count+StringLen($AFind[$x])-1) $index += 1 $Exist = True EndIf Next $Exist = False Next _ArrayDisplay($NewFilePaths)Saludos Edited July 15, 2015 by Danyfirex Update Code. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Danyfirex Posted July 15, 2015 Share Posted July 15, 2015 (edited) If you think you want to avoid _FileListToArray expandcollapse popup#include <Array.au3> Local $aFilePaths = ["Intel(R) 7 SeriesC216 Chipset Family PCI Express Root Port 1 - 1E10", _ "Intel(R) 7 SeriesC216 Chipset Family PCI Express Root Port 5 - 1E18", _ "Intel(R) 7 SeriesC216 Chipset Family SATA AHCI Controller", _ "Intel(R) 7 SeriesC216 Chipset Family SMBus Host Controller - 1E22", _ "Intel(R) 7 SeriesC216 Chipset Family Universal Serial Bus (USB) Controller - 1E1", _ "Intel(R) 7 SeriesC216 Chipset Family USB Enhanced Host Controller - 1E26", _ "Intel(R) 7 SeriesC216 Chipset Family USB Enhanced Host Controller - 1E2D", _ "NVIDIA High Definition Audio", _ "NVIDIA High Definition Audio#1", _ "NVIDIA High Definition Audio#2", _ "NVIDIA High Definition Audio#3", _ "Realtek High Definition Audio", _ "VMware Virtual Ethernet Adapter for VMnet1", _ "VMware Virtual Ethernet Adapter for VMnet8", _ "Xeon(R) processor E3-1200 v23rd Gen Core processor DRAM Controller - 0150", _ "Xeon(R) processor E3-1200 v23rd Gen Core processor PCI Express Root Port - 0151"] ;~ Create the directries to the test For $i=0 to UBound($aFilePaths)-1 DirCreate($aFilePaths[$i]) Next _ArrayDisplay($aFilePaths);show the directories Local $AFind[][] = [["Family", "Audio", "VMnet", "Core processor"], _ [False, False, False, False]] Local $sFolder = @ScriptDir & "\" Local $NewFilePaths[0] Local $index = 0 Local $Count = 0 Local $hSearch = FileFindFirstFile($sFolder & "*.") While 1 $sFileName = FileFindNextFile($hSearch) If @error Then ExitLoop For $i = 0 To UBound($AFind, 2) - 1 If $index > 1 Then If Not StringInStr($sFileName, $NewFilePaths[$index - 1]) Then $AFind[1][$i] = False EndIf $Count = StringInStr($sFileName, $AFind[0][$i]) If $AFind[1][$i] = True Then DirRemove($sFolder & $sFileName) If $Count And $AFind[1][$i] = False Then ReDim $NewFilePaths[UBound($NewFilePaths) + 1] $NewFilePaths[$index] = StringLeft($sFileName, $Count + StringLen($AFind[0][$i]) - 1) DirMove($sFolder & $sFileName, $sFolder & $NewFilePaths[$index]) $index += 1 $AFind[1][$i] = True EndIf Next WEnd _ArrayDisplay($NewFilePaths) ;Show the directories that we need and with the new namesSaludos Edited July 15, 2015 by Danyfirex I wrote. want avoid instead want to aviod lol Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut 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