saurabh2k26 Posted December 8, 2013 Share Posted December 8, 2013 Hi I have X number of images in D:/base and X number of images in D:/test. All images have same format and size and sorted alphabetically in both folders. I want to compare 1st image of D:/base with 1st image of D:/test, 2nd of D:/base with 2nd of D:/test and so on and save result in excel(or any other file, aim is just to get final report for all X images). Since my folders and files are fixed, i dont want unnecessary functions like FileOpenDialog, just all result in single function call. please help. Also, if you know some other tool for this function is ok. Link to comment Share on other sites More sharing options...
water Posted December 8, 2013 Share Posted December 8, 2013 (edited) Welcome to AutoIt and the forum! Do all the pictures in D:/base and D:/test have the same name? Means: Do you want to compare the content of the files or the content of the directories (= list of names)? Edited December 8, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 8, 2013 Moderators Share Posted December 8, 2013 saurabh2k26,Welcome to the AutoIt forum. I would get the hash for each of the file contents and then compare them. Look at the following functions in the Help file: _FileListToArray - to list the filesFileRead - to get their contents_Crypt_HashData - to get the hashFor...Next - to run the necessary loopsGive it a go yourself and see how you get on - you know where we are if you need a bit of help. 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...
water Posted December 8, 2013 Share Posted December 8, 2013 I've used WinMerge to compare the content of all files (images) in two directories. I wanted to check for new pictures for the companies directory. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
saurabh2k26 Posted December 8, 2013 Author Share Posted December 8, 2013 @Water D:/base have names as 1.jpg, 2.jpg etc. D:/test are actually gdi_snapshots taken at different time during a test and have names in format of date and time ex 2013-12-12T23hh13mm44sec.jpg, 2013-12-12T23hh15mm22sec.jpg. I want to compare image where 1.jpg is expected image of a test and 2013-12-12T23hh13mm44sec.jpg is actual image i got during running the test. @Melba Thanks for your help. Actually, i am very new to autoit. It would be great if you can help with full code. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 8, 2013 Moderators Share Posted December 8, 2013 saurabh2k26, It would be great if you can help with full codeWe do not normally do that here, we help you develop your own code - think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. But here is a rough idea of what "full code" should look like - I have not tested it:expandcollapse popup#include <File.au3> #include <Crypt.au3> Global $sPath_Base = "D:/base" Global $sPath_Base = "D:/test" _Crypt_Startup() ; Hash the base files $aList_Base = _FileListToArray($sPath_Base, "*", 1) Global $aHash_Base = [$aList_Base[0] + 1] For $i = 1 To $aList_Base[0] $sRead = FileRead($sPath_Base & "\" & $aList_Base[$i]) $aHash_Base[$i] = _Crypt_HashData($sRead, $CALG_MD5) Next ; Hash the test files $aList_Test = _FileListToArray($sPath_Test, "*", 1) Global $aHash_Test = [$aList_Test[0] + 1] For $i = 1 To $aList_Test[0] $sRead = FileRead($sPath_Test & "\" & $aList_Test[$i]) $aHash_Test[$i] = _Crypt_HashData($sRead, $CALG_MD5) Next ; Now we compare them For $i = 1 To $aList_Test[0] ; Compare this image with all the test images For $j = 1 To $aList_Base[0] ; If we find a match If $aHash_Test[$i] = $aHash_Base[$j] Then ; Say so ConsoleWrite($aList_Test[$i] & " matches " & $aList_Base[$j] & @CRLF) ; And move on to the next test image ExitLoop EndIf EndIf ; Check for a nil return If $j > $aList_Base[0] Then ConsoleWrite($aList_Test[$i] & " matched no base images" & @CRLF) EndIf Next ConsoleWrite("All done" & @CRLF) _Crypt_Shutdown()Give it a try and see if it works for you. 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...
saurabh2k26 Posted December 9, 2013 Author Share Posted December 9, 2013 (edited) Hi Melba I removed few syntax error from your code and run, but ti does not work. In console, all i get is "All done".expandcollapse popup#include <File.au3> #include <Crypt.au3> Global $sPath_Base = "D:\base" Global $sPath_Test = "D:\test" _Crypt_Startup() ; Hash the base files $aList_Base = _FileListToArray($sPath_Base, "*", 1) Global $aHash_Base = "[$aList_Base[0] + 1]" For $i = 1 To "$aList_Base[0]" $sRead = FileRead($sPath_Base & "\" & $aList_Base[$i]) $aHash_Base[$i] = _Crypt_HashData($sRead, $CALG_MD5) Next ; Hash the test files $aList_Test = _FileListToArray($sPath_Test, "*", 1) Global $aHash_Test = "[$aList_Test[0] + 1]" For $i = 1 To "$aList_Test[0]" $sRead = FileRead($sPath_Test & "\" & $aList_Test[$i]) $aHash_Test[$i] = _Crypt_HashData($sRead, $CALG_MD5) Next ; Now we compare them For $i = 1 To "$aList_Test[0]" ; Compare this image with all the test images For $j = 1 To "$aList_Base[0]" ; If we find a match If $aHash_Test[$i] = $aHash_Base[$j] Then ; Say so ConsoleWrite($aList_Test[$i] & " matches " & $aList_Base[$j] & @CRLF) ; And move on to the next test image ExitLoop EndIf ;EndIf Next ; Check for a nil return If $j > $aList_Base[0] Then ConsoleWrite($aList_Test[$i] & " matched no base images" & @CRLF) EndIf Next ConsoleWrite("All done" & @CRLF) _Crypt_Shutdown() Edited December 9, 2013 by Melba23 Added tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 9, 2013 Moderators Share Posted December 9, 2013 saurabh2k26,I did say I had not tested it. And there were a couple more silly mistakes you missed. To make up for it, this script has been tested on my system with my images - and it works perfectly:expandcollapse popup#include <File.au3> #include <Crypt.au3> Global $sPath_Base = "D:\base" Global $sPath_Test = "D:\test" _Crypt_Startup() ; Hash the base files $aList_Base = _FileListToArray($sPath_Base, "*", 1) Global $aHash_Base[$aList_Base[0] + 1] For $i = 1 To $aList_Base[0] $sRead = FileRead($sPath_Base & "\" & $aList_Base[$i]) $aHash_Base[$i] = _Crypt_HashData($sRead, $CALG_MD5) Next ; Hash the test files $aList_Test = _FileListToArray($sPath_Test, "*", 1) Global $aHash_Test[$aList_Test[0] + 1] For $i = 1 To $aList_Test[0] $sRead = FileRead($sPath_Test & "\" & $aList_Test[$i]) $aHash_Test[$i] = _Crypt_HashData($sRead, $CALG_MD5) Next ; Now we compare them For $i = 1 To $aList_Test[0] ; Compare this image with all the test images For $j = 1 To $aList_Base[0] ; If we find a match If $aHash_Test[$i] = $aHash_Base[$j] Then ; Say so ConsoleWrite($aList_Test[$i] & " matches " & $aList_Base[$j] & @CRLF) ; And move on to the next test image ExitLoop EndIf Next ; Check for a nil return If $j > $aList_Base[0] Then ConsoleWrite($aList_Test[$i] & " matched no base images" & @CRLF) EndIf Next ConsoleWrite("All done" & @CRLF) _Crypt_Shutdown()All good now? M23P.S. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. 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...
saurabh2k26 Posted December 9, 2013 Author Share Posted December 9, 2013 Hi Melba Thanks a lot. I used it in my application and i still need little more help. Issue1: I run my code by directly clicking my test.au3 and not by opening editor and then Go. So, i am not able to see the console. Can i somehow generate my output to excel file or notepad? Issue2: I want to match image 1 of D:base with image 1 of D:test (All images are sorted by name), but i observed that your code matched image 1 of D:/test with all images of D:/base. My result: 12-09-2013_@_1h53m30s%.jpg matches 1.jpg 12-09-2013_@_1h53m34s%.jpg matches 2.jpg 12-09-2013_@_1h53m41s%.jpg matches 3.jpg 12-09-2013_@_1h53m45s%.jpg matches 4.jpg 12-09-2013_@_1h53m54s%.jpg matches 5.jpg 12-09-2013_@_1h54m01s%.jpg matches 1.jpg 12-09-2013_@_1h54m05s%.jpg matches 7.jpg For red part, i wanted "no base image found" since it do not match 6.jpg Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted December 9, 2013 Moderators Solution Share Posted December 9, 2013 saurabh2k26, Can i somehow generate my output to excel file or notepad?Of course. Use Run to open Notepad and then Send to pass what was being written to the console to the app. I want to match image 1 of D:base with image 1 of D:test (All images are sorted by name)Then change the compare code to read like this:; Now we compare them For $i = 1 To $aList_Test[0] ; Compare this image with the relevant test image If $aHash_Test[$i] = $aHash_Base[$i] Then ConsoleWrite($aList_Test[$i] & " matches " & $aList_Base[$i] & @CRLF) Else ConsoleWrite($aList_Test[$i] & " does not match " & $aList_Base[$i] & @CRLF) EndIf NextI have not tested it - I am on my phone in a hospital waiting room - but it should work. 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...
saurabh2k26 Posted December 10, 2013 Author Share Posted December 10, 2013 Thanks, it worked perfectly fine. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 10, 2013 Moderators Share Posted December 10, 2013 saurabh2k26,Glad I could help. 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