Jump to content

Find MD5 Files and delete they


 Share

Recommended Posts

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

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

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

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 :x :

#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 :sweating:

Thanks

Edited by ElEsteban
Link to comment
Share on other sites

If you want to dump off the recursive folder hashing to a 3rd party tool, I have written MD5Hash

It 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 by MilesAhead
Link to comment
Share on other sites

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 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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...