ElEsteban Posted November 15, 2012 Share Posted November 15, 2012 Hello, this can be complicated... I want to use autoit for check and find a list of MD5 checksums in a folder, for example: Autoit Have this list of MD5: DABE2408B2C296A06ED10FF4DB42F74F 628D39E8E0F48E989BE6F69B8BAB08ED B9401D5EECB283B974B385EC53C1993F And when autoit found any file with this MD5, then delete it. It can be used de UDF tool of "Ward": But I dont kown how... Anyone knows how I can do this with autoit? i have been looking for a utility that do this, but I only find utilities that find duplicate files with MD5, not a custom list of MD5 files. Thanks and sorry for my english Link to comment Share on other sites More sharing options...
JohnOne Posted November 15, 2012 Share Posted November 15, 2012 You will need to list your files to an array (_FileListToArray). Get an MD5 has of each as you loop through the array. Compare each hash to the one you want to find. Delete it if found. In that order. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dany Posted November 15, 2012 Share Posted November 15, 2012 Last time I checked the standard library Crypt.au3 was faster than Ward's machine code, probably partially due because I'm on 64-bit. Either way, Crypt.au3 provides an easy function for hashing files: #include <Crypt.au3> Local $bFileHash = _Crypt_HashFile('pathtofile', $CALG_MD5) Return value is in Binary so you'll have to Hex() it first before comparing to a string. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
ElEsteban Posted November 16, 2012 Author Share Posted November 16, 2012 (edited) Hello, thanks for the replys, im trying generate this script, but there is too much for me to learn... The first thing, i want to check the MD5 of all files in a folder and all subfolder-> Dir1Dir3File3 Dir1File4 Dir2File5 File1 File2 The next thing i dont kown is how to compare every file in the array with my list of MD5... This is the bad code i generated : #include <File.au3> #include <Crypt.au3> #include <Array.au3> Local $Folderinuse = "C:Folder" Local $FileList = _FileListToArray($Folderinuse,"*",1) For $A = 1 To $FileList[0] Local $bFileHash = _Crypt_HashFile($FileList[$A], $CALG_MD5) How i can continue this? Too dificult to my little brain Thanks Edited November 16, 2012 by ElEsteban Link to comment Share on other sites More sharing options...
MilesAhead Posted November 16, 2012 Share Posted November 16, 2012 (edited) If you want to dump off the recursive folder hashing to a 3rd party tool, I have written MD5HashIt is free for youj to use at your own risk. It's written in VC++ and comes with 32 and 64 bit native compiled exes.There's a couple of AutoIt scripts with it to add and remove it from the Explorer Context Menu.Basically, right click a folder and select Md5Hash. It recursively searches the folder adding all the files to a queue. Once it starts hashing, there's a running total of the remaining files to process. For large files it shows a progress bar. It comes up with hash white space and file path on each line. There's a button hat cuts the results to the clipboard.You can also use it on individual files. I made it as a Gui to check for identical files quickly. With MD5 usually if the first 4 characters of the hash are the same, the rest will be. The Dialog accepts drag and drop. It also has "single instance" hehaviour if you open one copy before say right clicking on a group of files. I did it that way so that I could still open another instance for large video files rather than bog down a list of smaller files etc..I'm not sure if it's useful to you. You might be able to run it via AutoIt macro control and select results to clipboard etc..Anyway, it includes a Readme.txt for more details. Pressing F1 while the dialog has the focus displays an About Box.edit: the maxium queue length is 4096 files. If you need to do something like recursively hash from C: down then you'll need a different tool. Edited November 16, 2012 by MilesAhead My Freeware Page Link to comment Share on other sites More sharing options...
JohnOne Posted November 16, 2012 Share Posted November 16, 2012 (edited) Short basic demo based on your own start. #include <File.au3> #include <Crypt.au3> #include <Array.au3> Local $Folderinuse = @ScriptDir & '' Local $FileList = _FileListToArray($Folderinuse, "*", 1) Local $hash = _Crypt_HashFile($Folderinuse & "temp.bmp", $CALG_MD5) ; choose a file in your script folder ConsoleWrite($hash & @LF) For $A = 1 To $FileList[0] If _Crypt_HashFile($Folderinuse & $FileList[$A], $CALG_MD5) = $hash Then MsgBox(0,0,"Found: " & $FileList[$A]) Exit EndIf Next Edited November 16, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ElEsteban Posted November 18, 2012 Author Share Posted November 18, 2012 Thanks MilesAhead and JohnOne MilesAhead your tool is great, but it stop adding files to the list in the 4096 like you say. I need to check MD5 for more files, anyway Thank you a lot. JohnOne your demo works!! but only in one dir, not all subfolders/files, and taking one file as MD5 for compare. How can i solve this? How i can convert "$CALG_MD5" binary data to hex for compare with a list of MD5? When it found a file, how the script can delete it? Thanks Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2012 Share Posted November 18, 2012 Was not meant to be a solution, just a demonstration. For example, where the message box is, you would deal with the file. Melba23 has a great recursive file lister _RecFileListToArray I believe. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
dany Posted November 18, 2012 Share Posted November 18, 2012 How i can convert "$CALG_MD5" binary data to hex for compare with a list of MD5?Return value is in Binary so you'll have to Hex() it first before comparing to a string. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF 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