D4rk^S0ul Posted December 12, 2005 Share Posted December 12, 2005 Is it possible to get all the folder names in a defined folder? I have searched the forum but i couldnt find anything that i could use Link to comment Share on other sites More sharing options...
trids Posted December 12, 2005 Share Posted December 12, 2005 Capture the output (of which there are several methods) from the following DOS cmd .. dir /ad /b BTW .. to capture all child folders as well, use this instead .. dir /ad /b /s Link to comment Share on other sites More sharing options...
DaveF Posted December 12, 2005 Share Posted December 12, 2005 The popular way to do this has been with FindFind... and FileGetAttrib, here's a thread with an example.To find this I searched the forum for +FileFind* and +FileGetAttrib* Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
randallc Posted December 13, 2005 Share Posted December 13, 2005 Hi,To expand on trids' remark;try this (cd link in my sig to doscoms.au3);DosSwitchesFolderExample1.au3#include<DOSComs.au3>$Folder=@ScriptDir$t = TimerInit();_DIR($Folder, "/4/O-g/O-d/n/b/s"); **============This lists all folders and sub-folders in $Folder directory_DIR($Folder, "/ad/s")ConsoleWrite(Timerdiff($t) & @CRLF);@TempDir & "\FileList.tmp" RunWait("Notepad.exe " &@TempDir & "\FileList.tmp",@ScriptDir,@SW_SHOW)Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
D4rk^S0ul Posted December 13, 2005 Author Share Posted December 13, 2005 Thx for the help but is there anyway i can do it in the script so i can return the answer as a defined name? So i can make a combo of the names. Link to comment Share on other sites More sharing options...
GaryFrost Posted December 13, 2005 Share Posted December 13, 2005 (edited) #include <GuiConstants.au3> #include <GuiCombo.au3> Opt('MustDeclareVars',1) Dim $Combo,$ret,$Btn_Exit,$Status,$msg,$allocated GuiCreate("ComboBox Add Dir", 392, 254) $Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE) $ret = _GUICtrlComboAddDir($Combo,"D,E", "*.*") $Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop EndSelect WEnd Exit Edited December 13, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
ChrisL Posted December 13, 2005 Share Posted December 13, 2005 Thx for the help but is there anyway i can do it in the script so i can return the answer as a defined name? So i can make a combo of the names. You could probably addapt this expandcollapse popup#include <file.au3> processFolder(@scriptDir) func processFolder($path) local $fileHandle, $file, $dirHandle, $dir local const $FILESPEC = "*.*" ; debug("Starting with " & $path) ; debug("Going to search for " & $path & "\" & $FILESPEC) $fileHandle = fileFindFirstFile($path & "\" & $FILESPEC) if ($fileHandle <> -1) then while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file if (isFolder($file)) then continueLoop ;debug("Found file " & $file) wEnd fileClose($fileHandle) endIf ; debug("Going to search for subfolders") $dirHandle = fileFindFirstFile($path & "\*.*") if ($dirHandle <> -1) then while (1) $dir = fileFindNextFile($dirHandle) if (@error = 1) then exitLoop if ($dir = "." or $dir = "..") then continueLoop $dir = $path & "\" & $dir if (not(isFolder($dir))) then continueLoop debug("Found subfolder " & $dir) processFolder($dir) wEnd fileClose($dirHandle) endIf endFunc func isFolder($path) if stringInStr(fileGetAttrib($path), "D") then return 1 return 0 endFunc func debug($text) msgBox(0x40, "processFolder()", $text) endFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
randallc Posted December 13, 2005 Share Posted December 13, 2005 Thx for the help but is there anyway i can do it in the script so i can return the answer as a defined name? So i can make a combo of the names.From my script, simply loop through filereadline from the answerFile?...randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Valuater Posted December 13, 2005 Share Posted December 13, 2005 (edited) another choice is FileListToArray() example #include <GUIConstants.au3> #Include <File.au3> $Location = @ProgramFilesDir $FileList=_FileListToArray($Location, "*.*", 2) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf GUICreate("My GUI combo"); will create a dialog box that when displayed is centered GUICtrlCreateCombo ("", 10,10); create first item For $x = 1 to $FileList[0] GUICtrlSetData(-1,$FileList[$x],"|"); add other item send set a new default Next GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend 8) Edited December 13, 2005 by Valuater Link to comment Share on other sites More sharing options...
randallc Posted December 14, 2005 Share Posted December 14, 2005 (edited) $ret = _GUICtrlComboAddDir($Combo,"D,E", "*.*")How good is that!Randall Edited December 14, 2005 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
GaryFrost Posted December 14, 2005 Share Posted December 14, 2005 $ret = _GUICtrlComboAddDir($Combo,"D,E", "*.*") D = DIRECTORY - Includes subdirectories. Subdirectory names are enclosed in square brackets ([ ]). E = EXCLUSIVE - Includes only files with the specified attributes. By default, read-write files are listed even if READWRITE is not specified. "*.*" - can have a path to look in also i.e. c:\*.* SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
seandisanti Posted December 14, 2005 Share Posted December 14, 2005 alot of good replies; i just wanted to toss in another alternative... this is a recursive file lister that i made as an example for another thread, currently it starts at root of c and lists all sub files and folders and their size. if you change 3-4 lines, you should be able to create an output file of just the directories, and make an input box/fileopendialog()/etc to take user input on where to start.... $tosearch = "C:" $output = FileOpen("c:\filelist.txt",2) Global $deep = 0 $start = TimerInit() RecFileSearch($tosearch) FileClose($output) MsgBox(0,"done","it only took " & int(TimerDiff($start)/1000) & " seconds") Func RecFileSearch($current) $deep = $deep +1 Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file)<1 Then ExitLoop FileWriteLine($output,$current & "\" & $file & " " & FileGetSize($file)) If StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) Then RecFileSearch($current & "\" & $file) WEnd FileClose($search) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now