Jump to content

Match the rest of folder name


iahngy
 Share

Recommended Posts

Is there a way to look up for a folder name but I just know half part of it by using autoit coding?

for example, my full folder names are HG1234_1972, HG1234_1973, HG1234_1975 .....

it just has the same name before underscore  but different number after underscore  and I only know the name HG1234 ...

is there  a way to code so it can list all folders with that name HG1234?

 

Link to comment
Share on other sites

  • Moderators

iahngy,

Yes, look at _FileListToArray (or _FileListToArrayRec if the folders are not within the same folder) - both accept wildcards in the path parameter and both will list folders as well as files. :)

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

I was so bored....I decided to write a function for you...

Local $sFolders = GetMatchingFolders('C:\FullPathTo\Folder\YouWant\ToSearch', 'HG1234_')
If $sFolders Then
    Local $aFolders = StringRegExp($sFolders, '([^\|]+)', 3)
    For $f In $aFolders
        MsgBox(0, '', $f)
    Next
EndIf

Func GetMatchingFolders($sSearchRoot, $sStartsWith)
    Local $hFound = FileFindFirstFile($sSearchRoot & '\*'), $sNext, $sMatches
    If $hfound <> -1 Then
        While 1
            $sNext = FileFindNextFile($hFound)
            If @error Then
                ExitLoop
            ElseIf @extended Then
                If StringInStr($sNext, $sStartsWith) = 1 Then $sMatches &= $sSearchRoot & '\' & $sNext & '|'
            EndIf
        WEnd
    EndIf
    FileClose($hFound)
    Return $sMatches
EndFunc

                                  an even more bored person

  

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