Jump to content

Folder sifter


Recommended Posts

I am looking for a method to select folders and files alike for a File list compilation with the *.dec extension. Here is what I have, I'm pretty sure my problem is with "FileOpenDialog" however I don't know what to put in it's place.

Case $Compile
            $var=FileOpenDialog("Hold down Ctrl or Shift to choose multiple files.","Decks\","Apprentice Decks (*.dec)",1+4);Allows selection of files, Stored to string $var.
            If @error Then
                MsgBox(4096,"","No File(s) chosen");Message box when cancel is clicked.
                Exit
            Else
                $var=StringReplace($var,"|",@CRLF);String->Array function
                MsgBox(4096,"Files","You chose " & $var);String->Array Display
            EndIf
            $attrib = FileGetAttrib($var)
            If @error Then
                MsgBox(4096,"Error", "Could not obtain attributes.")
                Exit
            Else
                If StringInStr($attrib, "D") Then;Checks if file selected is a folder.(Auto search function)
                    FileChangeDir($var)
                    $search=FileFindFirstFile("*.dec"); Catches the first file in search.
                    $Dir=stringreplace(@WorkingDir,@ScriptDir,"");gets local folder directory if in same folder as working script, or gets full path of deck
                    While 1
                        $file=FileFindNextFile($search);Search for subsequent files
                        If @error Then ExitLoop;end loop when no more files are found
                        $file=StringReplace($file,".dec","");remove .dec extension
                        IniWrite("result.ini","Custom Deck",$file,$Dir);writes list to ini with the local folder name shortcut.
                    WEnd
                EndIf
            EndIf
            If StringInStr($attrib, "N") Then;Checks if file selected is a normal file.(Auto search function)
                $search=FileFindFirstFile("*.dec"); Catches the first file in search.
                $Dir=stringreplace(@WorkingDir,@ScriptDir,"");gets local folder directory if in same folder as working script, or gets full path of deck
                While 1
                    $file=FileFindNextFile($search);Search for subsequent files
                    If @error Then ExitLoop;end loop when no more files are found
                    $file=StringReplace($file,".dec","");remove .dec extension
                    IniWrite(@ScriptDir&"result.ini","Custom Deck",$file,$Dir);writes list to ini with the local folder name shortcut.
                WEnd
            EndIf
            MsgBox(0, "Notice", "You will need to restart MTG Deck Viewer in order for the deck list to refresh.")
            FileClose($search); Close the search handle

Edit:Forgot the color (code->autoit)

Edited by AceSentinal

:blink: What just happened?

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