Search the Community
Showing results for tags 'duplicates'.
-
_GetDuplicates.au3 Returns an array of duplicate values in a 2D or 1D array. on the occasion of the post ; https://www.autoitscript.com/forum/topic/211972-get-the-duplicates-value-of-array/ ;---------------------------------------------------------------------------------------- ; Title...........: _GetDuplicates.au3 ; Description.....: Returns an array of duplicate values in a 2D or 1D array. ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Array.au3> #include <File.au3> #include <FileConstants.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"] ;~ $aDuplicates = _GetDuplicates($aFilms) ;~ _ArrayDisplay($aDuplicates, "$aDuplicates") ; Display the unique array. ;~ Exit ; Find all Duplicates song from the "D:\Music\Bob Marley" folder Global $aFileInfo = _PropertiesListToArray("D:\Music\Bob Marley", "*.mp3;*.wma", "20, 14, 26, 21, 16, 28", 1) _ArrayDisplay($aFileInfo, "$aFileInfo") Global $aDuplicates = _GetDuplicates($aFileInfo, 4) _ArrayDisplay($aDuplicates, "$aDuplicates") ; Display the unique array. ConsoleWrite("Report Duplicates =============================" & @CRLF) Global $aDbl ConsoleWrite("Duplicates count: " & $aDuplicates[0] & @CRLF) For $i = 1 To $aDuplicates[0] $aDbl = StringSplit($aDuplicates[$i], ";") ConsoleWrite($i & ") " & $aFileInfo[$aDbl[1]][4]) ConsoleWrite(" - " & $aDbl[0] & " file(s)" & @CRLF) For $z = 1 To $aDbl[0] ConsoleWrite(@TAB & "found in " & $aFileInfo[$aDbl[$z]][0] & @CRLF) Next Next ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _PropertiesListToArray() ; Description ...: Lists files from specified path with Ext properties ; Syntax.........: _PropertiesListToArray($sFolderPath [, $sMask = "*" [, $sGetDetailsOf = "1, 2, 3, 4, 6" [, $iRecur = 0]]) ; Parameters ....: $sFolderPath - Initial path used to generate filelist. ; : $sMask - [optional] Filter for result. Multiple filters must be separated by ";" ; : $sGetDetailsOf - [optional] The Column of properties to return ; : $iRecur - [optional] 0=Do not search in subfolders ,1=Search in all subfolders ; Return value...: 2D Array ; Author ........: ioa747 ; Notes .........: ;-------------------------------------------------------------------------------------------------------------------------------- Func _PropertiesListToArray($sFolderPath, $sMask = "*", $sGetDetailsOf = "1, 2, 3, 4, 6", $iRecur = 0) Local $hTimer = TimerInit() Local $oShell = ObjCreate("Shell.Application") Local $oDir = $oShell.Namespace($sFolderPath) ConsoleWrite("$sFolderPath=" & $sFolderPath & @CRLF) Local $aFiles = _FileListToArrayRec($sFolderPath, $sMask, $FLTAR_FILES, $iRecur, $FLTAR_FASTSORT, $FLTAR_FULLPATH) If @error Then Local $sError = "Path not found or invalid;Invalid Include parameter;Invalid Exclude parameter;" $sError &= "Invalid Exclude_Folders parameter;Invalid $iReturn parameter;Invalid $iRecur parameter;" $sError &= "Invalid $iSort parameter;Invalid $iReturnPath parameter;No files/folders found" Local $aErr = StringSplit($sError, ";", 2) ToolTip($aErr[@extended] & @CRLF & " ", @DesktopWidth / 4, @DesktopHeight / 2, "Error:", 2) Sleep(4000) ToolTip("") Return SetError(1, @extended, "") EndIf Local $aColumns = StringSplit($sGetDetailsOf, ", ", 1) Local $aData[$aFiles[0] + 1][1] For $i = 1 To $aColumns[0] _ArrayColInsert($aData, $i) $aData[0][$i] = $oDir.GetDetailsOf($oDir.Items, $aColumns[$i]) Next $aData[0][0] = UBound($aData) - 1 Local $sDir, $sFileName, $oFile Local $iUnitCnt = 100 / $aFiles[0] ProgressOn("Progress...", "Search for " & $sMask & " files", "0%") For $i = 1 To $aFiles[0] $sDir = StringLeft($aFiles[$i], StringInStr($aFiles[$i], "\", 0, -1)) $sFileName = StringMid($aFiles[$i], StringInStr($aFiles[$i], "\", 0, -1) + 1) $aData[$i][0] = $aFiles[$i] $oDir = $oShell.NameSpace($sDir) $oFile = $oDir.Parsename($sFileName) For $c = 1 To $aColumns[0] $aData[$i][$c] = $oDir.GetDetailsOf($oFile, $aColumns[$c]) Next ProgressSet($i * $iUnitCnt, Round($i * $iUnitCnt, 0) & "%") Next ProgressSet(100, "Done", "Complete") ProgressOff() ConsoleWrite($aFiles[0] & " files processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @LF) Return $aData EndFunc ;==>_PropertiesListToArray ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _GetDuplicates ; Description....: Returns an array of duplicate values in a 2D or 1D array. ; Syntax.........: _GetDuplicates($aArray, $iColumn = 0) ; Parameters.....: $aArray - The input array. ; $iColumn - [Optional] The column index to check for duplicates (default is 0). ; Return values..: An array of duplicate values. ; Author ........: ioa747 ; Notes .........: This function assumes that the input array is a 2D or 1D array. ;-------------------------------------------------------------------------------------------------------------------------------- Func _GetDuplicates(ByRef $aArray, $iColumn = 0) Local $sStrIndex, $iDuplCnt Local $aDuplicates[] = [0] Local $aIndex[UBound($aArray)] For $i = 0 To UBound($aArray) - 1 If $aIndex[$i] = "Duplicates" Then ContinueLoop $sStrIndex = "" $iDuplCnt = 0 For $d = 0 To UBound($aIndex) - 1 Local $iColCnt = UBound($aArray, 2) ;ConsoleWrite("$iColCnt=" & $iColCnt & @CRLF) If $iColCnt > 0 Then ; if $aArray = 2D If $aArray[$i][$iColumn] = $aArray[$d][$iColumn] Then $sStrIndex &= $d & ";" $iDuplCnt += 1 If $iDuplCnt > 1 Then $aIndex[$d] = "Duplicates" EndIf Else ; if $aArray = 1D If $aArray[$i] = $aArray[$d] Then $sStrIndex &= $d & ";" $iDuplCnt += 1 If $iDuplCnt > 1 Then $aIndex[$d] = "Duplicates" EndIf EndIf Next $sStrIndex = StringTrimRight($sStrIndex, 1) ;ConsoleWrite("$sStrIndex=" & $sStrIndex & @CRLF) $aIndex[$i] = $sStrIndex Local $asplit = StringSplit($sStrIndex, ";") If $asplit[0] > 1 Then ReDim $aDuplicates[UBound($aDuplicates) + 1] $aDuplicates[0] += 1 $aDuplicates[$aDuplicates[0]] = $sStrIndex EndIf Next Return $aDuplicates EndFunc ;==>_GetDuplicates #cs $sGetDetailsOf - The Column of properties to return [0] = Name [1] = Size [2] = Item type [3] = Date modified [4] = Date created [5] = Date accessed [6] = Attributes [7] = Offline status [8] = Availability [9] = Perceived type [10] = Owner [11] = Kind [12] = Date taken [13] = Contributing artists [14] = Album [15] = Year [16] = Genre [17] = Conductors [18] = Tags [19] = Rating [20] = Authors [21] = Title [22] = Subject [23] = Categories [24] = Comments [25] = Copyright [26] = # [27] = Length [28] = Bit rate [29] = Protected [30] = Camera model [31] = Dimensions [32] = Camera maker [33] = Company [34] = File description [35] = Masters keywords [36] = Masters keywords [42] = Program name [43] = Duration [44] = Is online [45] = Is recurring [46] = Location [47] = Optional attendee addresses [48] = Optional attendees [49] = Organizer address [50] = Organizer name [51] = Reminder time [52] = Required attendee addresses [53] = Required attendees [54] = Resources [55] = Meeting status [56] = Free/busy status [57] = Total size [58] = Account name [60] = Task status [61] = Computer [62] = Anniversary [63] = Assistant's name [64] = Assistant's phone [65] = Birthday [66] = Business address [67] = Business city [68] = Business country/region [69] = Business P.O. box [70] = Business postal code [71] = Business state or province [72] = Business street [73] = Business fax [74] = Business home page [75] = Business phone [76] = Callback number [77] = Car phone [78] = Children [79] = Company main phone [80] = Department [81] = E-mail address [82] = E-mail2 [83] = E-mail3 [84] = E-mail list [85] = E-mail display name [86] = File as [87] = First name [88] = Full name [89] = Gender [90] = Given name [91] = Hobbies [92] = Home address [93] = Home city [94] = Home country/region [95] = Home P.O. box [96] = Home postal code [97] = Home state or province [98] = Home street [99] = Home fax [100] = Home phone [101] = IM addresses [102] = Initials [103] = Job title [104] = Label [105] = Last name [106] = Mailing address [107] = Middle name [108] = Cell phone [109] = Nickname [110] = Office location [111] = Other address [112] = Other city [113] = Other country/region [114] = Other P.O. box [115] = Other postal code [116] = Other state or province [117] = Other street [118] = Pager [119] = Personal title [120] = City [121] = Country/region [122] = P.O. box [123] = Postal code [124] = State or province [125] = Street [126] = Primary e-mail [127] = Primary phone [128] = Profession [129] = Spouse/Partner [130] = Suffix [131] = TTY/TTD phone [132] = Telex [133] = Webpage [134] = Content status [135] = Content type [136] = Date acquired [137] = Date archived [138] = Date completed [139] = Device category [140] = Connected [141] = Discovery method [142] = Friendly name [143] = Local computer [144] = Manufacturer [145] = Model [146] = Paired [147] = Classification [148] = Status [149] = Status [150] = Client ID [151] = Contributors [152] = Content created [153] = Last printed [154] = Date last saved [155] = Division [156] = Document ID [157] = Pages [158] = Slides [159] = Total editing time [160] = Word count [161] = Due date [162] = End date [163] = File count [164] = File extension [165] = Filename [166] = File version [167] = Flag color [168] = Flag status [169] = Space free [172] = Group [173] = Sharing type [174] = Bit depth [175] = Horizontal resolution [176] = Width [177] = Vertical resolution [178] = Height [179] = Importance [180] = Is attachment [181] = Is deleted [182] = Encryption status [183] = Has flag [184] = Is completed [185] = Incomplete [186] = Read status [187] = Shared [188] = Creators [189] = Date [190] = Folder name [191] = Folder path [192] = Folder [193] = Participants [194] = Path [195] = By location [196] = Type [197] = Contact names [198] = Entry type [199] = Language [200] = Date visited [201] = Description [202] = Link status [203] = Link target [204] = URL [208] = Media created [209] = Date released [210] = Encoded by [211] = Episode number [212] = Producers [213] = Publisher [214] = Season number [215] = Subtitle [216] = User web URL [217] = Writers [219] = Attachments [220] = Bcc addresses [221] = Bcc [222] = Cc addresses [223] = Cc [224] = Conversation ID [225] = Date received [226] = Date sent [227] = From addresses [228] = From [229] = Has attachments [230] = Sender address [231] = Sender name [232] = Store [233] = To addresses [234] = To do title [235] = To [236] = Mileage [237] = Album artist [238] = Sort album artist [239] = Album ID [240] = Sort album [241] = Sort contributing artists [242] = Beats-per-minute [243] = Composers [244] = Sort composer [245] = Disc [246] = Initial key [247] = Part of a compilation [248] = Mood [249] = Part of set [250] = Period [251] = Color [252] = Parental rating [253] = Parental rating reason [254] = Space used [255] = EXIF version [256] = Event [257] = Exposure bias [258] = Exposure program [259] = Exposure time [260] = F-stop [261] = Flash mode [262] = Focal length [263] = 35mm focal length [264] = ISO speed [265] = Lens maker [266] = Lens model [267] = Light source [268] = Max aperture [269] = Metering mode [270] = Orientation [271] = People [272] = Program mode [273] = Saturation [274] = Subject distance [275] = White balance [276] = Priority [277] = Project [278] = Channel number [279] = Episode name [280] = Closed captioning [281] = Rerun [282] = SAP [283] = Broadcast date [284] = Program description [285] = Recording time [286] = Station call sign [287] = Station name [288] = Summary [289] = Snippets [290] = Auto summary [291] = Relevance [292] = File ownership [293] = Sensitivity [294] = Shared with [295] = Sharing status [297] = Product name [298] = Product version [299] = Support link [300] = Source [301] = Start date [302] = Sharing [303] = Availability status [304] = Status [305] = Billing information [306] = Complete [307] = Task owner [308] = Sort title [309] = Total file size [310] = Legal trademarks [311] = Video compression [312] = Directors [313] = Data rate [314] = Frame height [315] = Frame rate [316] = Frame width [317] = Spherical [318] = Stereo [319] = Video orientation [320] = Total bitrate [321] = CMYK Profile [322] = Primary color mode [323] = Colors [324] = Effects [325] = External bitmaps [326] = Fills [327] = Fonts used [328] = Fonts embedded [329] = Grayscale Profile [330] = Languages [331] = Layer names [332] = Object count [333] = Object names [334] = Objects [335] = Outlines [336] = Page names [337] = Paper orientation [338] = Paper size [339] = Color palettes [340] = Rendering intent [341] = RGB Profile [342] = Spot colors [343] = Styles [344] = Bitmap compression [345] = Compression ratio [346] = Graphic compression [347] = Color mode [348] = Color Profile [349] = Audio tracks [350] = Bit depth [351] = Contains chapters [352] = Content compression [353] = Subtitles [354] = Subtitle tracks [355] = Video tracks #CE $sGetDetailsOf - The Column of properties to return Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
-
Hello everyone , Let's say I have an array that contains these numbers: 2,5,7,2,25,6,31,1,24,5,7,8,7,99 How would I make my program be able to tell me something like "There are three 7's". Is it possible to make an array detect duplicates and notify you? Thanks, Brian
-
Referring to a question posted here, this is a possible SQL query that should do: supposed you have an sqlite table named 'multimedia' with a column named 'sha1_hash', and you want to see only rows with the 'sha1_hash' value that appears more than one time within the table, you could use an SQL query like this: SELECT sha1_hash, COUNT(sha1_hash) AS sha1_sum FROM multimedia GROUP BY sha1_hash HAVING sha1_sum>1 ORDER BY sha1_sum DESC; this query should show only records with the value of sha1_hash that appears more times also in other records, showing it only one time, with a column indicating how many occurrences are present, ordered from the most recurring to the least recurring one. I don't know if this query can be simplified a bit...?, .... if there is a simpler way I would like some hint, Thanks
-
Hello everyone, I just have a beginner question: is there a way to count duplicates in an array? If you don't see what I mean, here is an example of what I mean: $arr[5] = ['a', 'a', 'b', 'b', 'c'] ; the array countDuplicates($arr); Representing the data in a bidimensionnal array, this would return: #cs ['a'][2] ['b'][2] ['c'][1] Of course this is a bit messy, but that's just for you to get the idea #ce I'm trying to achieve this to check whether yes or no an array has more or same amount of occurrences of a character than another array. Am I doing this the right way? Does such a function exist? Thanks for everything
- 7 replies
-
- array
- duplicates
-
(and 2 more)
Tagged with: