rst Posted October 20, 2004 Posted October 20, 2004 Does any one knew if there is a to use autoit to list all folders in a folder?
konan Posted October 20, 2004 Posted October 20, 2004 I think this is what you need!http://www.autoitscript.com/forum/index.php?showtopic=2753
sPeziFisH Posted October 20, 2004 Posted October 20, 2004 (edited) modify _FileSearch (I guess $sCP or $sbuffer is the variable for you (maybe just after some changes)) - here's the link to eezetabi's version, may be easier to understand.There's also Larry's version (the original one)edit: haven't updated the browser-window, konan just gave the tip Edited October 20, 2004 by sPeziFisH
trids Posted October 20, 2004 Posted October 20, 2004 (edited) Or you can simply redirect the result of a dir /ad /b to a temporary file which you can then read and split into an array. edit: like this ... #8487 Edited October 20, 2004 by trids
sPeziFisH Posted October 20, 2004 Posted October 20, 2004 (edited) ..but that's the same with filesearch: dir ...directory... /S /B edit: where ...directory... can be with mask, for instance c:\blabla\*.au3 Edited October 20, 2004 by sPeziFisH
trids Posted October 20, 2004 Posted October 20, 2004 Is it .. ? I only saw options based on FileFind* commands - sorry, perhaps I looked at the wrong link
sPeziFisH Posted October 20, 2004 Posted October 20, 2004 .. I mean 'dir ..directory & mask... /S /B' gives the same like the _FileSearch-function. But I preper _FileSearch as I don't want to write and read files, and stdout to variable is not possible AFAIK
ezzetabi Posted October 20, 2004 Posted October 20, 2004 Just adding two lines... I wrote what ones, if it does not work, you know where look... expandcollapse popupFunc _FolderSearch($sIstr, $bSF) ; $bSF = 1 means looking in subfolders ; $sSF = 0 means looking only in the current folder. ; An array is returned with the full path of all files found. The pos [0] keeps the number of elements. Local $sIstr, $bSF, $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1] $sCP = StringLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCP = '' Then $sCP = @WorkingDir & '\' $sCriteria = StringTrimLeft($sIstr, StringInStr($sIstr, '\', 0, -1)) If $sCriteria = '' Then $sCriteria = '*.*' ;To begin we seek in the starting path. $sCS = FileFindFirstFile($sCP & $sCriteria) While $sCS <> - 1 $sCF = FileFindNextFile($sCS) If @error Then FileClose($sCS) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If Not StringInStr($sCP & $sCF,FileGetAttrib($sCP & $sCF),'d') Then ContinueLoop ;;ADDED LINE $sOutPut = $sOutPut & $sCP & $sCF & @LF Wend ;And after, if needed, in the rest of the folders. If $bSF = 1 Then $sBuffer = @CR & $sCP & '*' & @LF;The buffer is set for keeping the given path plus a *. Do $sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1),1);current search. $sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1));Current search path. $iH = FileFindFirstFile($sCS) While $iH <> - 1 $sCF = FileFindNextFile($iH) If @error Then FileClose($iH) ExitLoop EndIf If $sCF = '.' Or $sCF = '..' Then ContinueLoop If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then $sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer;Every folder found is added in the begin of buffer $sFP = $sCP & $sCF & '\'; for future searches $iH2 = FileFindFirstFile($sFP & $sCriteria); and checked with the criteria. While $iH2 <> - 1 $sCF2 = FileFindNextFile($iH2) If @error Then FileClose($iH2) ExitLoop EndIf If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop If Not StringInStr($sFP & $sCF2,FileGetAttrib($sFP & $sCF2),'d') Then ContinueLoop;;ADDED LINE $sOutPut = $sOutPut & $sFP & $sCF2 & @LF;Found items are put in the Output. Wend EndIf Wend $sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '') Until $sBuffer = '' EndIf If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf EndFunc ;==>_FileSearch
JSThePatriot Posted October 20, 2004 Posted October 20, 2004 A way I decided to find directories was right out of the help file. So long as there are no files in the folder containing the other directories (or files with the same name you can use what I found in the help file). Here is what the help file has... ; Shows the filenames of all files in the current directory, note that "." and ".." are returned. $search = FileFindFirstFile("*.*") ; Check if the search was successful If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd ; Close the search handle FileClose($search) If you run that really quickly you will notice that it shows the folders to. So long as you arent wanting to go into sub directories that will work. If you want sub directories... use Larry's or ezzetabi's. The above is much less code if you just want the directories. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)
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