asgarcymed Posted November 23, 2007 Posted November 23, 2007 When using Windows Script Host, we can use the "Dictionary Object"... « Set dict = CreateObject("Scripting.Dictionary") » Does AutoIt have something built-in like Dictionary Object? Or it is obligatory to use the "Dictionary Object", via ObjCreate? Thanks. Regards. MLMK - my blogging craziness...
SkinnyWhiteGuy Posted November 23, 2007 Posted November 23, 2007 Afraid not, you either have to use the Scripting.Dictionary object and use it, or create your own set of functions. I opted to create my own, due to some computers I run scripts on not having that object (Wine is good, but not that good). I'm not home now to post what I have, but if you don't have to worry about that, go for the COM object. Search around, there are some functions on the boards to help you out with them, made my GaryFrost if I remember right.
asgarcymed Posted November 24, 2007 Author Posted November 24, 2007 When it becomes possible to you, please, post what you have... Thanks. Regards. MLMK - my blogging craziness...
ptrex Posted November 24, 2007 Posted November 24, 2007 @asgarcymed I am not sure why you are looking for the dictionary functionality ? Because if you use the ARRAY functions in AU3 you should come a long way. Regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Zedna Posted November 24, 2007 Posted November 24, 2007 Here is link to script using ObjCreate("Scripting.Dictionary")It's in Example1.au3 Resources UDF ResourcesEx UDF AutoIt Forum Search
GaryFrost Posted November 24, 2007 Posted November 24, 2007 Was also done Here a several months ago. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
SkinnyWhiteGuy Posted November 25, 2007 Posted November 25, 2007 Made it home, posting the file now. Function names are the same as Gary's he linked to, just with an additional beginning parameter on each (the actual object to be acted on). Used to have both methods in the function calls (Scripting.Object, and mine), but it kept messing up, so I took out the Scripting Object method to test mine out. Works well.Dictionary.au3
asgarcymed Posted November 25, 2007 Author Posted November 25, 2007 ptrex - Why am I looking for the dictionary functionality ? - please look at:http://www.autoitscript.com/forum/index.ph...c=57778&hl=I am trying to make an AutoIt script able to search for true duplicate files (same SIZE + same MD5 HASH/CHECKSUM), and after deleting clones...Since nobody has help me here, I asked for help in VBS Forums, and everybody said to use the "Dictionary Object" in order to detect repeated file's size and md5...Thank you, to all you, for replying to this topic!!! PS - If you want to help about the creation of an AutoIt script able to search for true duplicate files (same SIZE + same MD5 HASH/CHECKSUM), and after deleting clones; your help will be welcome!!!!I am still confused and doubtful...Thanks.Regards. MLMK - my blogging craziness...
randallc Posted November 25, 2007 Posted November 25, 2007 (edited) Hi, My func for removing the dupes may be a starting point, then look up the other file specs and how to get them?.... Best, randall [PS This is part of the filelisttoarraynew in link in my signature..] Func _ArrayDeleteDupes(ByRef $arrItems) If @OSTYPE = "WIN32_WINDOWS" Then Return 0 Local $i = 0, $objDictionary = ObjCreate("Scripting.Dictionary") For $strItem In $arrItems If Not $objDictionary.Exists ($strItem) Then $objDictionary.Add ($strItem, $strItem) EndIf Next ReDim $arrItems[$objDictionary.Count ] For $strKey In $objDictionary.Keys $arrItems[$i] = $strKey $i += 1 Next $arrItems[0 ]=$objDictionary.Count -1 Return 1 EndFunc ;==>_ArrayDeleteDupes Edited November 25, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
asgarcymed Posted November 25, 2007 Author Posted November 25, 2007 randallc - you have "the gold" I was looking for! Could you please post an example/sample (AU3 code) how to use your function [from: $target-path = InputBox ("Target Path...", "What is the target path to detect and delete duplicate files?")]? Thanks. Regards. MLMK - my blogging craziness...
randallc Posted November 25, 2007 Posted November 25, 2007 Hi, Did you already look at the examples in the zip from the link in my sig? If they don't help, you'll need to explain more clearly what you want.. Are the duplicated files ; 1. In the same directory? 2. In a number of subdirectories with the same name/ different anmes? Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
asgarcymed Posted November 25, 2007 Author Posted November 25, 2007 *) There are different main paths which may have dupes; for example: $path1 = "C:\Main" $path2 = "D:\Main" $path3 = "E:\Main" *) I need to define "inclusion and/or exclusion filters"; for example (search only for *.pdf and *.chm files; or, search *.* except *.doc). *) I would like to create an "automatically delete" method, by previously defining "automatic deletion rules": First rule => Whenever possible, delete all dupes located at any path except my preferred path ($path1)... Second rule => If dupes exist exactly inside my preferred path ($path1), then delete the dupes which have shorter filename length (StringLen). If dupes are exactly inside my preferred path ($path1) and have the same filename length, then delete the dupes which newer file's creation date (analyze: year, month, day, hour, minute, second). What is a dupe (duplicate file)? It may be: *) "Perfect/true duplicate" => same size (bytes) + same hash/checksum (as md5 or sha1) *) "Not sure however highly probable dupes" => same size (bytes) + same name *) "Doubtful however probable dupes" => approximately same size + approximately same name (approximately same size means: size(file1) = size(file2) + or - 100 bytes) (approximately same name means: First => analyze all filename's string Second => use StringSplit to try to isolate "words" (delimiters: space bar, comma, semicolon, dot) (exclude the final dot + extension; for example, exclude: ().pdf) Third => analyze filename's string fragments/splits/words, and if many of them are equal, file are very related. For example: "Java for Dummies - CRC Press.pdf" and "CRC Press- Java for Dummies.pdf" This is what I dream with... However I need help; my knowledge needs to be improved in order to be able to do that... Hope and thank for your help Best regards. MLMK - my blogging craziness...
asgarcymed Posted November 28, 2007 Author Posted November 28, 2007 I tried, as strategy: use, as dictionary's keys, the combination of [$size & $md5]. As dictionary's items, I use Full Path (which, of course, includes the name of each file). I tried to use the dictionary's "Exists" method, which checks and does not allow 2 keys to be equal. Thus, if a true duplicate file exists, the keys (combination of [$size & $md5]) would be equal... This is the way how to "hunt"/"catch" the true duplicate files... In theory, I think I am correct; however, in practice I am making something wrong, because my script never catches true duplicate files (and I voluntary copied the same file many times; just to test/debug my script)... Here it is: #Include <File.au3> #Include <Array.au3> $path = "L:\mais eBooks\0000\TESTES" $files_list_array = _FileListToArray($path, "*.*") For $n = 1 To $files_list_array[0] $file_size_bytes = FileGetSize($path & "\" & $files_list_array[$n]) $md5_object = ObjCreate("XStandard.MD5") ; "ActiveX=COM Component to easily get MD5 Hash/CheckSum ; It is FreeWare!!!... If interested, look at: ; http://www.xstandard.com/en/documentation/xmd5/ $md5_hash = $md5_object.GetCheckSumFromFile ($path & "\" & $files_list_array[$n]) $dict = ObjCreate("Scripting.Dictionary") $dict.CompareMode = 1 ; "Text Mode" $dict_key = $file_size_bytes & $md5_hash $dict_item = $path & "\" & $files_list_array[$n] If Not $dict.Exists ($dict_key) Then $dict.Add ($dict_key, $dict_item) ; MsgBox (0, "", $dict_key & Chr(13) & $dict_item) ElseIf $dict.Exists ($dict_key) Then FileWrite(@DesktopDir & "\Dupes.csv", $dict_item & "," & $dict_key & Chr(13)) EndIf Next Can you please help me to correct/debug this script? Thanks. Regards. MLMK - my blogging craziness...
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