blumi Posted March 7 Share Posted March 7 I have a folder with movies in it. I read this folder and add the filenames into an array. Now I want to find the duplicates, I have a function that works but not exactly as needed. In the folder are for example some names like this Rambo I Rambo II Rambo III The problem, the result lists me Rambo II as a duplicate, cause it exitsts in the name Rambo III How to modify the function that only exact the same names are recognized as duplicates and not the ones that are contained in a filename? Func FindeDuplikate( $aArray ) Local $oTst = ObjCreate( "Scripting.Dictionary" ) Local $oRes = ObjCreate( "Scripting.Dictionary" ) For $i = 0 To UBound( $aArray ) - 1 If Not $oTst.Exists( $aArray[$i] ) Then $oTst( $aArray[$i] ) = 1 ElseIf Not $oRes.Exists( $aArray[$i] ) Then $oRes( $aArray[$i] ) = 1 EndIf Next Return $oRes.Keys() EndFunc Link to comment Share on other sites More sharing options...
water Posted March 7 Share Posted March 7 You can query and modify the compare mode of the Scripting.Dictionary as described here. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Nine Posted March 7 Share Posted March 7 Scripting.Dictionary will not mix "Rambo II" with "Rambo III". I believe you got another problem somewhere. Here a simple way to test it : #include <Array.au3> Local $aList = ["Rambo I", "Rambo II", "Rambo III", "RAMBO I", "Rambo ii"] Local $aDup = FindeDuplikate($aList) _ArrayDisplay($aDup) Func FindeDuplikate( $aArray ) Local $oTst = ObjCreate( "Scripting.Dictionary" ) Local $oRes = ObjCreate( "Scripting.Dictionary" ) ;$oTst.CompareMode = 1 For $i = 0 To UBound( $aArray ) - 1 If Not $oTst.Exists( $aArray[$i] ) Then $oTst( $aArray[$i] ) = 1 ElseIf Not $oRes.Exists( $aArray[$i] ) Then $oRes( $aArray[$i] ) = 1 EndIf Next Return $oRes.Keys() EndFunc As you can see none is duplicate, but if you uncomment the line of CompareMode, then comparaison will be non-case-sensitive, so last two will be flagged as duplicates. SOLVE-SMART 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
UEZ Posted March 7 Share Posted March 7 (edited) Something like this here? #include <Array.au3> Global $aFilms[] = ["Rambo", "Rambo II", "Rambo III", "Rocky", "Rocky II", "Rocky III", "Rocky IV", "Possessed", "Edge of Tomorrow", "The Ghost Writer", "rocky ii", "RAMBO iii"] Global $aDuplicates[UBound($aFilms) * 2], $j = 0 For $i = 0 To UBound($aFilms) - 1 $aDuplicates[$j] = $aFilms[$i] $j += 1 If Random() < 0.3333333 Then $aDuplicates[$j] = $aFilms[$i] $j += 1 EndIf Next ReDim $aDuplicates[$j - 1] ;_ArrayShuffle($aDuplicates) _ArraySort($aDuplicates) ConsoleWrite("All " & UBound($aDuplicates) & " films:" & @CRLF) For $i = 0 To UBound($aDuplicates) - 1 ConsoleWrite($i + 1 & ": " & $aDuplicates[$i] & @CRLF) Next ConsoleWrite(@CRLF) ConsoleWrite("Duplicates:" & @CRLF) $i = -1 $j = 1 While $i < UBound($aDuplicates) - 2 $i += 1 If StringLower($aDuplicates[$i]) == StringLower($aDuplicates[$i + 1]) Then ConsoleWrite($j & ". duplicate: " & $aDuplicates[$i] & @CRLF) $j += 1 $i += 1 EndIf WEnd Edited March 7 by UEZ ioa747 and SOLVE-SMART 2 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
ioa747 Posted March 7 Share Posted March 7 look at the Reveal hidden content in the link below https://www.autoitscript.com/forum/topic/198175-zplayer-my-own-little-audiovideo-player/page/8/#comment-1528675 I believe it would help $aFileInfo = _PropertiesListToArray("F:\Movies\_New\_New films", "*.mp4;*.mkv;*.avi;*.flv", "1, 27, 196, 316, 314, 315, 320, 349, 355", 1) I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted June 14 Share Posted June 14 (edited) better late than never 211972-get-the-duplicates-value-of-array/ Edited June 14 by ioa747 I know that I know nothing 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