Sign in to follow this  
Followers 0
Thatsgreat2345

Get Files In A Folder

6 posts in this topic

Ok i know there filefindfirstfile and filefindnextfile but thats for the folder that the prog is in but im making an installer and is there a way to get all the files in a folder that is selected? ive been workin on it about 30 minutes last night on my laptop so im not very far but eh whatever :)

#include <GUIConstants.au3>
#include <file.au3>
; == GUI generated with Koda ==
$gui = GUICreate("Ainstalit", 485, 534, 192, 125)
$Group1 = GUICtrlCreateGroup("Program Information", 8, 8, 465, 177)
GUICtrlCreateLabel("Program Name", 16, 32, 74, 17)
$progname = GUICtrlCreateInput("", 96, 32, 281, 21, -1, $WS_EX_CLIENTEDGE)
$Browseinsall = GUICtrlCreateButton("Browse...", 384, 72, 73, 25)
GUICtrlCreateLabel("Instal Directory", 16, 72, 74, 17)
$installdir = GUICtrlCreateInput("", 96, 72, 281, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Directory Install", 16, 104, 76, 17)
$directory = GUICtrlCreateInput("", 96, 104, 281, 21, -1, $WS_EX_CLIENTEDGE)
$dirinstall = GUICtrlCreateButton("Browse...", 384, 104, 73, 25)
GUICtrlCreateLabel("Main Executable", 16, 136, 83, 17)
$mainexe = GUICtrlCreateInput("", 96, 136, 281, 21, -1, $WS_EX_CLIENTEDGE)
$browseexe = GUICtrlCreateButton("Browse...", 384, 136, 73, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Extra", 8, 200, 465, 81)
GUICtrlCreateLabel("Desktop Icon", 16, 224, 68, 17)
$desktop = GUICtrlCreateCheckbox("desktop", 88, 224, 17, 17)
GUICtrlCreateLabel("Start Menu", 16, 248, 56, 17)
$start = GUICtrlCreateCheckbox("start", 88, 248, 17, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Registry", 8, 296, 465, 65)
GUICtrlCreateLabel("Add to Registry", 16, 320, 76, 17)
$reg = GUICtrlCreateCheckbox("reg", 96, 320, 17, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group4 = GUICtrlCreateGroup("Export Information", 8, 376, 465, 97)
GUICtrlCreateLabel("Name of File", 16, 400, 63, 17)
$namefile = GUICtrlCreateInput("", 88, 400, 193, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlCreateLabel("Save Location", 16, 432, 73, 17)
$savelocation = GUICtrlCreateInput("", 88, 432, 225, 21, -1, $WS_EX_CLIENTEDGE)
$savebrowse = GUICtrlCreateButton("Browse...", 320, 432, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Go = GUICtrlCreateButton("Create It", 184, 488, 97, 33)
GUISetState(@SW_SHOW)


Do
    $msg = Guigetmsg()
Select
    
Case $msg = $Browseinsall
    $prog = guictrlread($progname)
    $browseinslocation = FileSelectFolder("Install Directory","C:\Program Files")
    guictrlsetdata($installdir,"")
    guictrlsetdata($installdir,$browseinslocation & "\" & $prog)
    
Case $msg = $dirinstall
    
    $directorylocation = Fileselectfolder("File to Install","")
    Guictrlsetdata($directory,"")
    guictrlsetdata($directory,$directorylocation )
Case $msg = $browseexe
    $mainexelocation = guictrlread($directory)
    $exelocation = FileOpenDialog("Main Executable", $mainexelocation,"Executables(*.exe)", 1 + 4)
    guictrlsetdata($mainexe,"")
    guictrlsetdata($mainexe,$exelocation)
Case $msg = $savebrowse
    $filename = Guictrlread($namefile)      
    $locationsave  = FileSelectFolder("Place to Save","C:\Documents and Settings\Desktop")
    guictrlsetdata($savelocation,"")
    If $filename = ($filename & ".au3") then
        $filename1 = $filename
        guictrlsetdata($savelocation,$locationsave & "\" & $filename1)
    elseif $filename = $filename Then
        $filename2 = ($filename & ".au3")
        guictrlsetdata($savelocation,$locationsave & "\" & $filename2)

EndIf

Case $msg = $Go
If Guictrlread($progname) = "" Then
Msgbox(0,"Error","Please Fill in every form")
Elseif GUICtrlRead($installdir) = "" Then
Msgbox(0,"Error","Please Fill in every form")
Elseif Guictrlread($directory) = "" Then
Msgbox(0,"Error","Please Fill in every form")
Elseif Guictrlread($mainexe) = "" Then
Msgbox(0,"Error","Please Fill in every form")
Elseif guictrlread($namefile) = "" Then
Msgbox(0,"Error","Please Fill in every form")
Elseif GUICtrlRead($savelocation) = "" Then
Msgbox(0,"Error","Please Fill in every form")
endif

EndSelect
    
    
    until $msg = $GUI_EVENT_CLOSE

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Uhm.. move the script ..

However, once i had this strange error that caused a ini to be written in the wrong map.. Uhm, it was like, Open something in a different map and then write the ini to nomap data.ini that caused it to be written in the map that i opened.. I hope this makes sence, i think it has something to do with a active directory or something

[edit] Don't move the script make the default script copy a prewritten script to the map you want to search in, use filefindfirstfile and filefindnextfile in the prewritten script and write the values to a ini. Make the default pause and read the data in the ini with a little loop, should be simple enough. :)

Edited by Manadar

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hahah yes i thought of that just forgot to come back and post that i did :) thx for the reply though

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

$PATH = "C:\Documents and Settings\One\Desktop\Inbox"
$FILEHANDLE = FileFindFirstFile($PATH & "\*.*")
$FILENAME = FileFindNextFile($FILEHANDLE)
If @error = 1 Then ExitLoop

supply the path and you can view the contents of any folder, doesn't matter where the au3 script is. or am i not understanding your question

Share this post


Link to post
Share on other sites

$PATH = "C:\Documents and Settings\One\Desktop\Inbox"
$FILEHANDLE = FileFindFirstFile($PATH & "\*.*")
$FILENAME = FileFindNextFile($FILEHANDLE)
If @error = 1 Then ExitLoop

supply the path and you can view the contents of any folder, doesn't matter where the au3 script is. or am i not understanding your question

thx :) exactly what i was lookin for thanks

Share this post


Link to post
Share on other sites

you're welcome!

Share this post


Link to post
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
Sign in to follow this  
Followers 0