Jump to content

Need Help with Folder Searches


Stalker0
 Share

Recommended Posts

Greetings everyone, I'm brand new to the boards and to autoit. I'm working on my 1st script, and I need a little help.

What I have is a list of folders:

001_something

002_something different

003_something entirely different

etc

The numbering is sequential and organized, what comes after the underscore can be completely random.

From a GUI perspective, I would like to be able for the user to create a list of numbers they want to work with. If anyone can help me with that it would be great but its not my priority.

What I need to do is once I know what number the user is looking for, I need to search the list of folders for that number (00X) and open it.

Any help the board could give would be greatly appreciated.

Link to comment
Share on other sites

Greetings everyone, I'm brand new to the boards and to autoit. I'm working on my 1st script, and I need a little help.

What I have is a list of folders:

001_something

002_something different

003_something entirely different

etc

The numbering is sequential and organized, what comes after the underscore can be completely random.

From a GUI perspective, I would like to be able for the user to create a list of numbers they want to work with. If anyone can help me with that it would be great but its not my priority.

What I need to do is once I know what number the user is looking for, I need to search the list of folders for that number (00X) and open it.

Any help the board could give would be greatly appreciated.

Here's a quick and dirty example (code untested):

#include<File.au3>
#include<GUIConstants.au3>
;#include<array.au3>

$rootfolder = "C:\test"
$folderlist = _FileListToArray($rootfolder, "*", 2)
$matchfound = 0

GUICreate("Folder Selection", 250, 100)
GUICtrlCreateLabel("Enter the 3-digit number for the folder you wish to open.", 5, 5, 240,40)
$selectedfolder = GUICtrlCreateInput("", 5, 50, 240, 20, $ES_NUMBER)
$ButtonOK = GUICtrlCreateButton("OK", 100, 75, 50, 20)
GUISetState()

;_ArrayDisplay($folderlist)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $ButtonOK
            If $selectedfolder <> "" Then
                For $i = 1 To $folderlist[0]
                    If StringLeft($folderlist[$i], 3) = GUICtrlRead($selectedfolder) Then
                        $matchfound = 1
                        ShellExecute($rootfolder &"\" &$folderlist[$i])
                    Else
                    EndIf
                Next
                If $matchfound = 0 Then
                    MsgBox(64, "Error", "A matching folder number was not found.")
                EndIf
            EndIf
    EndSelect
WEnd

There may be a number of ways that may be a bit cleaner, but this is just a quick example to get you started.

Welcome to the forums!

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

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