buymeapc Posted October 28, 2011 Share Posted October 28, 2011 Hi all, I'm trying to create an application to compare file properties of one folder on a local system to another on a remote system. The file list gathers very quickly, but when it comes to gathering the properties of those files, it takes an extremely long time. It currently takes about 15 minutes to gather the information of approximately 100 dll's. How could I make this gathering of info quicker? Here's the code I'm using right now. Thank you!! expandcollapse popup#Include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <array.au3> Global $inetpub = "C:\inetpub\wwwroot" Global $rootFolderName = "HSS" Global $dllArray[500][4], $dllArrayRemote[500][4] _FileViewPopulate($inetpub&"\"&$rootFolderName&"\Optimizer", True) _CompareGUI() Func _CompareGUI() Local $compMsg $compareGUI = GUICreate("Compare Server Files", 800, 500, Default, Default, BitOr($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), -1) $localPath = GUICtrlCreateInput($inetpub&"\"&$rootFolderName&"\Optimizer", 10, 10, 250) $remotePath = GUICtrlCreateInput("\\110.231.247.113\c$\Inetpub\wwwroot\HSS\Optimizer", 450, 10, 250) $browseBtn1 = GUICtrlCreateButton("Browse", 270, 7, 80) $browseBtn2 = GUICtrlCreateButton("Browse", 710, 7, 80) $compareBtn = GUICtrlCreateButton("Compare", 360, 240, 80) $localList = GUICtrlCreateListView("File|Date|Version|Size", 10, 40, 340, 400) _GUICtrlListView_SetExtendedListViewStyle(GUICtrlGetHandle($localList), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER)) ;_GUICtrlListView_AddArray($localList, $dllArray) _GUICtrlListView_SetColumnWidth($localList, 0, 100) _GUICtrlListView_SetColumnWidth($localList, 1, 100) _GUICtrlListView_SetColumnWidth($localList, 2, 70) _GUICtrlListView_SetColumnWidth($localList, 3, 60) _GUICtrlListView_JustifyColumn($localList, 3, 1) $remoteList = GUICtrlCreateListView("File|Date|Version|Size", 450, 40, 340, 400) _GUICtrlListView_SetExtendedListViewStyle(GUICtrlGetHandle($remoteList), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER)) _GUICtrlListView_SetColumnWidth($remoteList, 0, 100) _GUICtrlListView_SetColumnWidth($remoteList, 1, 100) _GUICtrlListView_SetColumnWidth($remoteList, 2, 70) _GUICtrlListView_SetColumnWidth($remoteList, 3, 60) _GUICtrlListView_JustifyColumn($remoteList, 3, 1) For $i = 0 To UBound($dllArray)-1 $tmp = StringSplit($dllArray[$i][0], "\") _GUICtrlListView_AddItem($localList, $tmp[$tmp[0]]) _GUICtrlListView_AddSubItem($localList, $i, $dllArray[$i][1], 1) _GUICtrlListView_AddSubItem($localList, $i, $dllArray[$i][2], 2) _GUICtrlListView_AddSubItem($localList, $i, $dllArray[$i][3], 3) Next GUISetState() While 1 $compMsg = GUIGetMsg() Select Case $compMsg = $GUI_EVENT_CLOSE ExitLoop Case $compMsg = $browseBtn1 $loc = FileSelectFolder("Select a folder", "", 0, "", $compareGUI) If @error Then MsgBox(64, "", "Folder select cancelled.") Else GUICtrlSetData($localPath, $loc) EndIf Case $compMsg = $browseBtn2 $loc = FileSelectFolder("Select a folder", "", 0, "", $compareGUI) If @error Then MsgBox(64, "", "Folder select cancelled.") Else GUICtrlSetData($remotePath, $loc) EndIf Case $compMsg = $compareBtn ; Are the fields blank? If GUICtrlRead($localPath) = "" Or GUICtrlRead($remotePath) = "" Then MsgBox(32, "Missing Path", "A path is missing. Please enter a valid path.") Else ; Check to see if the remote path is UNC. If so, get the credentials If StringInStr(GUICtrlRead($remotePath), "\\") <> 0 Then $user = InputBox("User", "Please enter the user name for the remote share.", "", " M", 350, 120, Default, Default, Default, $compareGUI) $pass = InputBox("Password", "Please enter the password for the user for the remote share.", "", "*M", 350, 120, Default, Default, Default, $compareGUI) $sCommand = 'net use "' & GUICtrlRead($remotePath) & '" /USER:' & $user & " " & $pass Dim $cmdreturn = "" $stream = Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDIN_CHILD + $STDERR_CHILD) While 1 ; loop through the return from the command until there is no more $line = StdoutRead($stream) If @error Then ExitLoop $cmdreturn &= $line WEnd If $cmdreturn <> "" Then MsgBox(0, "", $cmdreturn) Else While 1 $line = StderrRead($stream) If @error Then ExitLoop If $line <> "" Then $cmdreturn &= $line Wend MsgBox(0, "STDERR read:", $cmdreturn) EndIf EndIf If FileExists(GUICtrlRead($remotePath)) Then $remoteFiles = _FileListToArray_Recursive(GUICtrlRead($remotePath), "*.dll", 1, 2, True) If IsArray($remoteFiles) Then For $x = 1 To UBound($remoteFiles) - 1 $file_date = FileGetTime($remoteFiles[$x], 0, 0) $date = $file_date[1] & "/" & $file_date[2] & "/" & $file_date[0] & " " & $file_date[3] & ":" & $file_date[4] $file_size = FileGetSize($remoteFiles[$x])/1024; Size in kb $file_size = Round($file_size); Round it up ; Add a comma if needed If StringLen($file_size) > 3 Then Dim $char, $charComma $char = StringLeft($file_size, 1) $charComma = $char & "," $file_size = StringReplace($file_size, $char, $charComma, 1) EndIf $file_size &= " KB" ;ConsoleWrite($Optdlls[$x]&"|"&$date&"|"&FileGetVersion($Optdlls[$x])&"|"&$file_size&@CRLF) $tmp = StringSplit($remoteFiles[$x], "\") _GUICtrlListView_AddItem($remoteList, $tmp[$tmp[0]]) _GUICtrlListView_AddSubItem($remoteList, $x-1, $date, 1) _GUICtrlListView_AddSubItem($remoteList, $x-1, FileGetVersion($remoteFiles[$x]), 2) _GUICtrlListView_AddSubItem($remoteList, $x-1, $file_size, 3) ;$temp_dll = StringSplit($Optdlls[$x], "\") $dllArrayRemote[$x-1][0] = $remoteFiles[$x];$temp_dll[$temp_dll[0]] $dllArrayRemote[$x-1][1] = $date $dllArrayRemote[$x-1][2] = FileGetVersion($remoteFiles[$x]) $dllArrayRemote[$x-1][3] = $file_size Next EndIf ReDim $dllArrayRemote[$remoteFiles[0]-1][4] EndIf $sCommand = 'net use "' & GUICtrlRead($remotePath) & '" /d'; Remove the drive once completed Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDIN_CHILD + $STDERR_CHILD) EndIf EndSelect WEnd GUIDelete($compareGUI) EndFunc Func _FileListToArray_Recursive($sPath, $sFilter = "*", $iRetItemType = 0, $iRetPathType = 0, $bRecursive = False) ; $iRetItemType: 0 = Files and folders, 1 = Files only, 2 = Folders only ; $iRetPathType: 0 = Filename only, 1 = Path relative to $sPath, 2 = Full path/filename Local $sRet = "", $sRetPath = "" Local $sOrigPathLen, $sCurrPathLen, $sCurrPath, $search, $file, $hSearch $sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sFilter, "[\\/ :> <\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "") $sPath &= "\|" $sOrigPathLen = StringLen($sPath) - 1 While $sPath $sCurrPathLen = StringInStr($sPath, "|") - 1 $sCurrPath = StringLeft($sPath, $sCurrPathLen) $search = FileFindFirstFile($sCurrPath & $sFilter) If @error Then $sPath = StringTrimLeft($sPath, $sCurrPathLen + 1) ContinueLoop EndIf Switch $iRetPathType Case 1 ; relative path $sRetPath = StringTrimLeft($sCurrPath, $sOrigPathLen) Case 2 ; full path $sRetPath = $sCurrPath EndSwitch While 1 $file = FileFindNextFile($search) If @error Then ExitLoop If ($iRetItemType + @extended = 2) Then ContinueLoop $sRet &= $sRetPath & $file & "|" WEnd FileClose($search) If $bRecursive Then $hSearch = FileFindFirstFile($sCurrPath & "*") While 1 $file = FileFindNextFile($hSearch) If @error Then ExitLoop If @extended Then $sPath &= $sCurrPath & $file & "\|" WEnd FileClose($hSearch) EndIf $sPath = StringTrimLeft($sPath, $sCurrPathLen + 1) WEnd If Not $sRet Then Return SetError(4, 4, "") Return StringSplit(StringTrimRight($sRet, 1), "|") EndFunc Func _FileViewPopulate($path, $recursive = True) Local $Optdlls, $file_date, $file_size, $date Dim $Optdlls $Optdlls = _FileListToArray_Recursive($path, "*.dll", 1, 2, $recursive) _ArrayDisplay($Optdlls) MsgBox(0, "", $Optdlls) If IsArray($Optdlls) Then For $x = 1 To UBound($Optdlls) - 1 $file_date = FileGetTime($Optdlls[$x], 0, 0) $date = $file_date[1] & "/" & $file_date[2] & "/" & $file_date[0] & " " & $file_date[3] & ":" & $file_date[4] $file_size = FileGetSize($Optdlls[$x])/1024; Size in kb $file_size = Round($file_size); Round it up ; Add a comma if needed If StringLen($file_size) > 3 Then Dim $char, $charComma $char = StringLeft($file_size, 1) $charComma = $char & "," $file_size = StringReplace($file_size, $char, $charComma, 1) EndIf $file_size &= " KB" $dllArray[$x-1][0] = $Optdlls[$x];$temp_dll[$temp_dll[0]] $dllArray[$x-1][1] = $date $dllArray[$x-1][2] = FileGetVersion($Optdlls[$x]) $dllArray[$x-1][3] = $file_size Next ReDim $dllArray[$Optdlls[0]-1][4] EndIf Return $Optdlls[0] EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2011 Moderators Share Posted October 28, 2011 buymeapc, Nothing jumps out at me as a major choke point. Perhaps this might help you pinpoint areas in your script which are running slowly and give you a pointer. 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...
buymeapc Posted October 28, 2011 Author Share Posted October 28, 2011 Thanks for the reply, Melba23! That's a neat utility. With all my searching over the years, I have never seen that. Thanks for pointing me to it. It goes to show what really awesome stuff people have posted to this forum! I found that if I comment out the FileGetVersion() and FileGetSize() functions, the script speeds up dramatically. Is there a better/quicker way to get this information, perhaps? Thanks!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 28, 2011 Moderators Share Posted October 28, 2011 buymeapc,With all my searching over the years, I have never seen thatIt just took me over 30 minutes to find it myself - and I thought I was good at searching here! As to alternatives to FileGetVersion and FileGetSize, alas I can offer none. My only thought is to compare something easier (like the MD5 hash) and then only get more details of the 2 files if the hash is not the same. At least that would save you some time - although of course it depends whether the most likely result is a match or not and whether the remote or local takes longer. 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 October 28, 2011 Share Posted October 28, 2011 I thought I was good at searching here!You are, because I somehow missed this little gem. 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 October 28, 2011 Moderators Share Posted October 28, 2011 guinness, At least I knew it was there to find - the trick was getting the search terms correct. 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 October 28, 2011 Share Posted October 28, 2011 That's a toughy! Just tried it myself with bowmore profile autoit script, but I suppose that's cheating. 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...
buymeapc Posted October 28, 2011 Author Share Posted October 28, 2011 (edited) buymeapc, It just took me over 30 minutes to find it myself - and I thought I was good at searching here! As to alternatives to FileGetVersion and FileGetSize, alas I can offer none. My only thought is to compare something easier (like the MD5 hash) and then only get more details of the 2 files if the hash is not the same. At least that would save you some time - although of course it depends whether the most likely result is a match or not and whether the remote or local takes longer. M23 Hmm...well, I'm trying to compare the dll's from one folder to another while displaying their details (date, size, version) just like the image below of Beyond Compare, but more watered down. So, I want to display all the files which is adding to the time to list all the details unfortunately... Edited October 28, 2011 by buymeapc Link to comment Share on other sites More sharing options...
buymeapc Posted November 1, 2011 Author Share Posted November 1, 2011 Is there another way to do this that might be more expedient? 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