Jump to content

_FileListToArrayRec() How to find the right files?


Recommended Posts

So if a reasonable amount of the leading characters in a name, match the previous, then group them?   You could probably also read the nzb, nfo, diz... as they usually contain the common string found in the names.

 

#include <File.au3>
#include <MsgBoxConstants.au3>


Global $aFileList[] = [25, _
        "####### 12 v12.0.00800 MultiLingual Genial78.par2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.part1.rar", _
        "####### 12 v12.0.00800 MultiLingual Genial78.part2.rar", _
        "####### 12 v12.0.00800 MultiLingual Genial78.part3.rar", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol00+01.PAR2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol01+02.PAR2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol03+04.PAR2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol07+08.PAR2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol15+13.PAR2", _
        "~~~~~~~.v.1.40.208-TE.nfo", _
        "~~~~~~~.v.1.40.208-TE.r00", _
        "~~~~~~~.v.1.40.208-TE.r01", _
        "~~~~~~~.v.1.40.208-TE.r02", _
        "~~~~~~~.v.1.40.208-TE.r03", _
        "~~~~~~~.v.1.40.208-TE.r04", _
        "~~~~~~~.v.1.40.208-TE.r05", _
        "~~~~~~~.v.1.40.208-TE.r06", _
        "~~~~~~~.v.1.40.208-TE.rar", _
        "~~~~~~~.v.1.40.nzb", _
        "~~~~~~~.v.1.40.par2", _
        "~~~~~~~.v.1.40.sfv", _
        "~~~~~~~.v.1.40.vol00+1.PAR2", _
        "~~~~~~~.v.1.40.vol01+2.PAR2", _
        "~~~~~~~.v.1.40.vol03+4.PAR2", _
        "~~~~~~~.v.1.40.vol07+6.PAR2"]


;~ Global $aFileList[] = [15, _
;~ "file_id.diz" , _
;~ "tapcla01.zip" , _
;~ "tapcla02.zip" , _
;~ "tapcla03.zip" , _
;~ "tapcla04.zip" , _
;~ "tapcla05.zip" , _
;~ "tapcla06.zip" , _
;~ "tapcla07.zip" , _
;~ "te.nfo" , _
;~ "tt55013a.zip" , _
;~ "tt5013b.zip" , _
;~ "tt55013c.zip" , _
;~ "tt5013d.zip" , _
;~ "tt5013e.zip"]


local $aOut[1]

For $i = 1 to ubound($aFileList) - 1
    If $i = 1 Then
        $aOut[0] = $aFileList[$i]
    Else
        $length = StringLen($aFileList[$i])
            If stringinstr($aOut[0] , stringleft($aFileList[$i] , floor($length / 2.8))) Then
                _ArrayAdd ($aOut , $aFileList[$i])
            Else
                _ArrayDisplay($aOut)
                ReDim $aOut[1]
                $aOut[0] = $aFileList[$i]
            EndIf
        EndIf
    Next

_ArrayDisplay($aOut)

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

Chimaera,

and show you an image of it

Please do not do that! Just send me the list as a text file or I have to read and retype each one.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

boththose,

Although I like your idea of stopping at the first "significant" increase in matches, I am not convinced that this would get every file of a family as the increase when a final trailing numeric character was removed might give a false positive. For example there could be an increase of 10 when ####1* is used to match, when there are 30+ ####* matches to come. And yet looking for over 10 more matches would fail if there were only 15 total to find.

 read the nzb, nfo, diz...

I prefer that approach - but will those files types always be present?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

True, if ultimately stuck brute forcing it there would have to be an additional step of normalizing the length with stringformat to have a prayer, and even then edgecases will abound.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

 

I prefer that approach - but will those files types always be present?

M23

​Not usually no, sometimes but not enough to rely on.

Just thinking out loud here could you split in chunks of four letters etc

then test by the chunk from the left rather than the letter

Open    Clon    er.Ul   traB   ox.v   1.40.   208-   TE

very few files would match Open as a word

?

Link to comment
Share on other sites

probably still lots of ways to break it:

 

#include <File.au3>
#include <MsgBoxConstants.au3>

Global $aFileList[] = [25, _
        "####### 12 v12.0.00800 MultiLingual Genial78.par2", _
        " 12 v12.0.00800 ####### MultiLingual Genial78.part1.rar", _
        " 12 v12.0.00800 MultiLingual Genial78.part2.rar", _
        "####### 12 v12.0.00800 MultiLingual ####### Genial78.part3.rar", _
        " 12 v12.0.00800 MultiLingual Genial78.vol00+01.PAR2 #######", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol01+02.PAR2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol03+04.PAR2", _
        "####### 12 v12.0.00800 MultiLingual Genial78.vol07+08.PAR2", _
        " 12 v12.0.00800 MultiLingual ####### Genial78.vol15+13.PAR2", _
        "~~~~~~~.v.sfv", _
        "~~~~~~~.v.1.40.208-TE000046324623770002.nfo", _
        "~~~~~~~.v.1.40.208-TE.r00", _
        "~~~~~~~.v.1.40.208-TE.r01", _
        "~~~~~~~.v.1.40.208-TE.r02", _
        "~~~~~~~.v.1.40.208-TE05.r03", _
        "~~~~~~~.v.1.40.208-TE.r0417351757", _
        "~~~~~~~.v.1.40.208-TE.r05asdfas", _
        "~~~~~~~.v.1.40.208-TE.r06", _
        "~~~~~~~.v.1.40.208-TE.rar41462347", _
        "~~~~~~~.v.1.40.nzb", _
        "~~~~~~~.v.1.40.par2", _
        "~~~~~~~.v.1.40.vol00+1.PAR2", _
        "~~~~~~~.v.1.40.vol01+2.PAR2", _
        "~~~~~~~.v.1.40.vol03+4.PAR2", _
        "~~~~~~~.v.1.40.vol07+6.PAR2"]



local $aOut[1]

For $i = 1 to ubound($aFileList) - 1
    If $i = 1 Then
        $aOut[0] = $aFileList[$i]
    Else
        $length = StringLen($aFileList[$i])
            $sBase = $aOut[0] & "00000000000000000000000000000000000000000000000000"
            $sTest = $aFileList[$i] & "00000000000000000000000000000000000000000000000000"
            If stringinstr($sBase , stringleft($sTest , floor($length / ceiling($length / 4)))) Then
                _ArrayAdd ($aOut , $aFileList[$i])
            Else
                _ArrayDisplay($aOut)
                ReDim $aOut[1]
                $aOut[0] = $aFileList[$i]
            EndIf
        EndIf
    Next

_ArrayDisplay($aOut)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

removed*

Edited by boththose
double post

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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