kylomas Posted December 16, 2011 Share Posted December 16, 2011 J1, This is providing a distraction from the boring shit that I was working on...The solutions offered so far do not seem complete to me. Please post your solution for comparison (learning) as I'm also coding something to solve this... Incidentally, is it true that each part of the filename (before and after the "_") are the same length within one file but may vary from file to file? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted December 16, 2011 Author Share Posted December 16, 2011 I have not done anything with it yet, been eating and watching a TV show. But I'm certain that bit of logic will get me underway. The two sides of _ are of varying length at their are no rules/pattern governing that. With the code posted by bothose, it will give me the first true file it finds. I will then remove all instances of files that are equal to the first part Or equal to the second, and loop it. 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...
kylomas Posted December 16, 2011 Share Posted December 16, 2011 J1, Exactly what I am working on now... kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jaberwacky Posted December 16, 2011 Share Posted December 16, 2011 J1, we are all awash in a quagmire of uncertainties. When you're buried under an avalanche of snow the best to determine your orientation is to spit. If the spit dribbles into your eye then you're upside down. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
iamtheky Posted December 16, 2011 Share Posted December 16, 2011 also bear in mind, my script returns all duplicates under the assumption that only the proper filename will be listed multiple times. So if there is a chance that these "wrong" numbers could end up having duplicates within the group you are evaluating....the quagmire expands. ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
JohnOne Posted December 16, 2011 Author Share Posted December 16, 2011 I don't doubt it, a smart person would use _ArrayUnique on the array first, to be sure they're not tampering with files that do not belong there. 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...
JohnOne Posted December 16, 2011 Author Share Posted December 16, 2011 (edited) J1, we are all awash in a quagmire of uncertainties. When you're buried under an avalanche of snow the best to determine your orientation is to spit. If the spit dribbles into your eye then you're upside down.hahaSome of us only have piss and dribble to look forward to, but I prefer mine down my chin.EDIT:Dribble that is. Edited December 16, 2011 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...
kylomas Posted December 16, 2011 Share Posted December 16, 2011 J1, The logic that I am persueing is: "Ladies and gentlemen, take my advice, pull down your pants and slide on the ice." - Sidney Friedman (MASH) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jaberwacky Posted December 16, 2011 Share Posted December 16, 2011 (edited) oh lawd I lolled so hard at that =D edit: that includes kylomas's post now Edited December 16, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 J1, Given the following test data (from kaotibliss's post) $a10[0]= "332333_14631" $a10[1]= "88888_44444" $a10[2]= "46588_44444" $a10[3]= "33333_65788" $a10[4]= "33333_11112" Which would you say are good file names? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2011 Author Share Posted December 17, 2011 (edited) One cannot be deduced from those. 1,2,3 and 4 are candidates for half of separate good file names, but neither can be confirmed. Edited December 17, 2011 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...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 J1, Yes, then M23's assertion is true. Can you add data to the above example that would deliniate a good file? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2011 Author Share Posted December 17, 2011 $a10[0]= "332333_14631" $a10[1]= "88888_44444" $a10[2]= "46588_44444" $a10[3]= "33333_65788" $a10[4]= "33333_11112" $a10[5]= "46588_45723" I have added [5] which you can use to deduce a good file name. You see it now? 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...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 (edited) J1, The good file name would be 46588_45723 and not 46588_44444 because 46588_44444 has dup last node? Also, Given "123_321" (good) "267_876" (good) "12_98" (good) "2223_7881" (good) "123_946" (good) "887_321" (bad) "456_321" (bad) "123_998" (good) Is this correct? kylomas Edit: I see your dilema, there is nothing here to distinguish between 123_321 and 887_321.... Edit2: back to M23's assertion...to find bad files we have to uniquely id good files... Edited December 17, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2011 Author Share Posted December 17, 2011 (edited) No, its good because both nodes are dupe. Any other file containing either first or last node are bad. I'm working with this at the moment. expandcollapse popup#include <File.au3> #include <Array.au3> $dir = @ScriptDir & "" $good = $dir & "good" $dump = $dir & "dump" While Not @error $FArray = _FileListToArray($dir, "*.lmi", 1) $tmp = Work($FArray) ; the name of the first file found which should be good name If FileExists($tmp) Then FileMove($dir & $tmp, $good & $tmp) ; if it is exist the move it EndIf $aTmp = StringSplit($tmp, "_", 3) ;these loops below get rid of other files that have either the first part or secong part in them For $i = $FArray[0] To 1 Step -1 If StringInStr($FArray[$i], $aTmp[0]) Then FileMove($dir & $FArray[$i], $dump & $FArray[$i], 8) EndIf Next For $i = $FArray[0] To 1 Step -1 If StringInStr($FArray[$i], $aTmp[1]) Then FileMove($dir & $FArray[$i], $dump & $FArray[$i], 8) EndIf Next WEnd Func Work($Array) Local $column1[$Array[0] + 1] Local $column2[$Array[0] + 1] For $i = 0 To UBound($Array) - 1 $Temp = StringSplit($Array[$i], "_") If @error Then ContinueLoop $column1[$i] = $Temp[1] $column2[$i] = $Temp[2] Next Local $FOUND = 0 For $k = UBound($column1) - 1 To 0 Step -1 For $i = UBound($column1) - 1 To 0 Step -1 If $column1[$k] = $column1[$i] And $i <> $k Then $FOUND = 1 Next If $FOUND = 1 Then $FOUND = 0 Else _ArrayDelete($column1, $k) EndIf Next For $k = UBound($column2) - 1 To 0 Step -1 For $i = UBound($column2) - 1 To 0 Step -1 If $column2[$k] = $column2[$i] And $i <> $k Then $FOUND = 1 Next If $FOUND = 1 Then $FOUND = 0 Else _ArrayDelete($column2, $k) EndIf Next If Not IsArray($column1) Or Not IsArray($column2) Then Return SetError(1) EndIf $Answer = $column1[0] & "_" & $column2[0] Return $Answer EndFunc ;==>Work EDIT: tags are a pain. Edited December 17, 2011 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...
kaotkbliss Posted December 17, 2011 Share Posted December 17, 2011 No, its good because both nodes are dupe.That's where I was (quickly) trying to go with my 2 minute code. Get a list of all 1st nodes that were duped, get a list of all 2nd nodes that were dupedThen start piecing them together looking for filenames. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 (edited) J1, This code will create an array of all files that are good. Without further qualifying criteria I cannot figure out how to determine which are "good" files from the list of "might be good" files. @koatkbliss - Seems like such a trivial thing, at first glance...right... expandcollapse popup; ; hammer and tongs method ; #include <array.au3> local $a10[10] local $a20[ubound($a10)][2] $a10[0]= "332333_14631" $a10[1]= "88888_44444" $a10[2]= "46588_44444" $a10[3]= "33333_65788" $a10[4]= "33333_11112" $a10[5]= "46588_45723" ;--------------------------------------- ; winnow out files that have to be good ;--------------------------------------- ; split file name to 2x array for $i = 0 to ubound($a10) - 1 if stringlen($a10[$i]) = 0 then continueloop $a30 = stringsplit($a10[$i],'_',2) $a20[$i][0] = $a30[0] $a20[$i][1] = $a30[1] Next ; find unique first nodes - iterate each element of array through itself - save dups to string local $save_ele, $save_dups for $i = 0 to ubound($a20) - 1 $save_ele = $a20[$i][0] for $j = 0 to ubound($a20) - 1 if $j <> $i and $a20[$j][0] == $save_ele then $save_dups &= $a20[$j][0] & 0x0 Next next ; find unique second nodes - iterate each element of array through itself - save dups to string for $i = 0 to ubound($a20) - 1 $save_ele = $a20[$i][1] for $j = 0 to ubound($a20) - 1 if $i <> $j and $a20[$j][1] == $save_ele then $save_dups &= $a20[$j][1] & 0x0 Next next ; run through array and blank all dups $a30 = stringsplit($save_dups,0x0,2) for $i = 0 to ubound($a30) - 1 for $j = 0 to ubound($a20) - 1 if $a20[$j][0] = $a30[$i] then $a20[$j][0] = '' $a20[$j][1] = '' endif if $a20[$j][1] = $a30[$i] then $a20[$j][0] = '' $a20[$j][1] = '' endif next next _arraydisplay($a20) I keep thinking that some clever SQL might do this nicely, however, I don't have the skills for this. Good Luck!!! kylomas Edited December 17, 2011 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
kylomas Posted December 17, 2011 Share Posted December 17, 2011 J1, One last thing (I just washed my keyboard with a large coffee). Does this make sense: if each node has dups than the entry that contains either node, where one of the nodes is unique, is the good file? Gotta go some of my keys are on coffee auto-repeat... Kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
JohnOne Posted December 17, 2011 Author Share Posted December 17, 2011 (edited) I'm not sure I follow, but I think you might be overcomplicating it (if that's possible). Given that this is a good file... 123_456 Then if another file begins with 123, then its opposite end will be totally unique. If a file ends in 456 then its opposite end will be totally unique. The only exception to this rule, is the good file, it is the only file where both ends have dupes. Edited December 17, 2011 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...
jaberwacky Posted December 17, 2011 Share Posted December 17, 2011 Why don't you ask Marilyn Vos Savant? So if a good file has 123_456 then any file that exists which has either the 123 or the 456 will considered a bad file? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? 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