blindwig Posted June 30, 2005 Share Posted June 30, 2005 (edited) I wrote a program to compare the recursive list of files and folders in 2 directories. I originally wrote this to test my _FileFindAllR and _Array1PullCommon UDFs, but ended up writing a new inline comparison routine that would be faster than my original one.The program has a GUI where you can set all the options, but it also accepts command-line parameters, so you can use it in a BAT file or something. Type DirectoryCompare /? from a command-line for help with command-line switches (or just look at the source, the help string is near the beginning).I learned something about comparing 2 lists:There were 2 ways I could think to do it, one would be to sort boths lists and then go line by line and compare them.The other way would be to sort just 1 list, and then use BinarySearch to compare the unsorted list against the sorted one. The Binary Search would of course be slower, but I was hoping it would off-set the time needed to sort both lists.Turns out that the 2nd method was about 4x slower than the first, so I went back to that.Anyway, have a look, tell me what you think.BTW, does anyone know how to write out to the console? So like if you called this program from a command-line, I could write message out to the console instead of in messageboxes?And what's the secrect to getting a screenshot to appear in a post? I can't seem to get this to work...edit: I removed the original attachments Edited July 9, 2005 by blindwig My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
blindwig Posted July 9, 2005 Author Share Posted July 9, 2005 OK, I updated my Directory Compare Program to use my multi-level progress bars. Still don't have a cancel button though, that's next...DirectoryCompare.zip My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
GaryFrost Posted July 9, 2005 Share Posted July 9, 2005 I'm using WinRar and get errors trying to extract the files. Oh well SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
blindwig Posted July 9, 2005 Author Share Posted July 9, 2005 I compressed them with Maximum compression, and there is a note that says that some older ZIP routines don't recognize this method. Try WinZip, that's what I'm using and it works. So does my copy of WinRar, v 3.42 (unregistered) My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
GaryFrost Posted July 9, 2005 Share Posted July 9, 2005 Was using an old 2.90 version (Registerd), downloaded the 3.42 (unregistered). Thanks, SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
blindwig Posted July 9, 2005 Author Share Posted July 9, 2005 Here's a screenshot. I tried adding this before but it wouldn't work. I just figured out that my allotment for attachment space on this board was all used up! My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
GaryFrost Posted July 9, 2005 Share Posted July 9, 2005 (edited) >Running: (3.1.1.56):C:\Program Files\AutoIt3\beta\autoit3.exe "C:\Documents and Settings\Gary\My Documents\Projects\DirectoryCompare\DirectoryCompare.au3" C:\Documents and Settings\Gary\My Documents\Projects\DirectoryCompare\DirectoryCompare.au3 (235) : ==> Subscript used with non-Array variable.: $FinalReport[$FinalReport[0][0]][0] = $DirList1ptr[$DirList1ptr] $FinalReport[$FinalReport[0][0]][0] = $DirList1ptr^ ERROR>AutoIT3.exe ended.Shoud be $DirList1[$DirList1ptr] Edited July 10, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
GaryFrost Posted July 10, 2005 Share Posted July 10, 2005 So far I like it, might come in handy been playing around with viewing the report, currently playing around with the RichText control, going to see what other controls might work good for that. If $Interactive Then _PreviewFile($gReportFile) Func _PreviewFile($s_file) $oRP = ObjCreate("RICHTEXT.RichtextCtrl.1") $GUI = GUICreate("Directory Compare Results", 500, 500, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_VISIBLE, $WS_CLIPSIBLINGS)) $GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 480, 480) GUICtrlSetPos($GUIActiveX, 10, 10, 480, 470) $LinkoRP = ObjEvent($oRP, "IEEvent_", "FolderView"); this is a dummy event handle With $oRP; Object tag pool .OLEDrag () .SelBullet = True If FileExists($s_file) Then .LoadFile ($s_file, 1) .Enabled = True .HideSelection = False .SelFontSize = 8 EndWith GUISetState();Show GUI While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete($GUI) EndFunc ;==>_PreviewFile SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
blindwig Posted July 10, 2005 Author Share Posted July 10, 2005 Thank for pointing that out - I don't know how I missed it. I guess in all my tests, Dir1 was always smaller than Dir2. I also added a feature I forgot to document - you can have multiple file masks, seperated by semi-colon. For example: '*.exe;*.dll;*.zip' But you know, just thinking about that - there is no check that a file matches multiple masks. For example, if you set the mask to '*.exe;a*.*', then AnyThing.Exe would show up twice in the report. Hmm... I'll have to think about that... Oh, and another bug in DoCompare() - notice that after WriteReport() I check @Error, but first I call TimerDiff, so @error gets destroyed. Need to use $Error like I did with DirectoryCompare() Oh, and I like your _PreviewFile function. I didn't know of a way to use a RichText box in AutoIt. I have a function I wrote, called _StringBox, for displaying strings that are just too big and/or obnoxious for MsgBox. Right now it uses an EditBox control, which has the 64KB limitation. I'll use your technique to change that to a RichTextBox. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
drunkfux Posted July 16, 2005 Share Posted July 16, 2005 If i were you i'd check the About button and carefully read how you spelled your own creation )) Think u'll find what i mean with this little hint Link to comment Share on other sites More sharing options...
blindwig Posted July 18, 2005 Author Share Posted July 18, 2005 If i were you i'd check the About button and carefully read how you spelled your own creation ))Think u'll find what i mean with this little hint <{POST_SNAPBACK}>Thanks for the report. Technically the problem isn't in the about box, it's in the $AppName assignment on line 7 of DirectoryCompare.au3 My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions Link to comment Share on other sites More sharing options...
Uten Posted September 27, 2005 Share Posted September 27, 2005 OK, I updated my Directory Compare Program to use my multi-level progress bars. Still don't have a cancel button though, that's next...Downloaded the code and tested it against the folders C:\temp\test\ C:\temp\test-foo\This triggers a wrong descission in MsgBox(1,"Test", Func _FileDirIsDecendant("C:\temp\test\", "C:\temp\test-foo\"))Modifying _FileGetTruePath toFunc _FileGetTruePath($sPath) Dim $LastDir = @WorkingDir, $Return If FileChangeDir($sPath) Then ;@WorkingDir does not return with a delimiter \ as the last char $Return = @WorkingDir & "\" FileChangeDir($LastDir) Else _DebugPrint("ERROR: FileChangedir(" & $sPath & ") failed") SetError(1) $Return = '' EndIf Return $Return EndFunc ;==>_FileGetTruePathWill do the trick to get comparing started but there is issues further down the lineC:\temp\autoit\DirectoryCompare\DirectoryCompare.au3 (238) : ==> Subscript used with non-Array variable.: $FinalReport[$FinalReport[0][0]][0] = $DirList1ptr[$DirList1ptr] $FinalReport[$FinalReport[0][0]][0] = $DirList1ptr^ ERRORC:\temp\autoit\DirectoryCompare\DirectoryCompare.au3 (570) : ==> Error in expression.: Local $aReport = DirectoryCompare($gDir1, $gDir2, $gCompareFlags, $gFileMask, $gAttribFilter) Local $aReport = ^ ERRORNot shure if this is fixed somwhere.Regards Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
busysignal Posted October 2, 2005 Share Posted October 2, 2005 Blindwig, Nice little utility.. Cheers.. 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