dimchik 0 Report post Posted August 27, 2008 May be some one could suggest how can i write a program which searches drive only 3 levels deep and returns folder with full path. Ex I have t drive T:\Client\Project_name\Project Soi want to scan and return only T:\Client\Project_name\Project1 T:\Client\Project_name\Project2 T:\Client\Project_name\Project3 T:\Client2\Project_name2\Project etc I owuld like to scan only folders i do not need files. Thank you for any help. Share this post Link to post Share on other sites
Prab 0 Report post Posted August 27, 2008 (edited) I just did something similar to this recently. I goes deeper than three levels, but just adding another parameter to the recursion should control that. Feel free to use this as a starting point and delete what you don't need. Edit: Looking over my code, I didn't comment it very well. If you have questions just ask. expandcollapse popup#include <GUIConstantsEx.au3> ; Shows the filenames of all files in the current directory. If ($CmdLine[0] > 0) Then $var = $CmdLine[1] Else $var = FileSelectFolder("Choose a folder to scan.", "", 0, "c:\") If (@error == 1) Then MsgBox(0, "Error", "That folder cannot be selected.") Exit EndIf EndIf $search = FileFindFirstFile($var & "\*.*") If ($search == -1) Then MsgBox(0, "Error", "The folder could not be opened.") Exit EndIf ; Check if the search was empty If (@error == 1) Then MsgBox(0, "Error", "The folder is empty") Exit EndIf $gui = GUICreate("Scanning Folder") $label = GUICtrlCreateInput("Line 1 Cell 1", 10, 10, 800) GUISetState(@SW_SHOW) $fileCount = 0 $answer = search($search, $var) $answer = "You have " & $fileCount & " files and folder in " & $var & @CRLF & @CRLF & $answer FileClose($search) $temp = FileSaveDialog("Choose where to save the log", @DesktopDir & "\", "Log (*.log;*.txt)", 16, "files.log") If (@error == 1) Then Exit EndIf $file = FileOpen($temp, 2) If ($file == -1) Then MsgBox(0, "Error", "Could not save file.") Exit EndIf FileWriteLine($file, $answer) FileClose($file) Func search($search, $var) $toReturn = "" While (True) $file = FileFindNextFile($search) If @error Then ExitLoop EndIf $toReturn = $toReturn & $var & "\" & $file & @CRLF $fileCount += 1 If mod($fileCount, 10) = 0 Then;only update the display every 10 files; helps speed GUICtrlSetData($label, $var & "\" & $file) EndIf $attrib = FileGetAttrib($var & "\" & $file) If StringInStr($attrib, "D") Then $search2 = FileFindFirstFile($var & "\" & $file & "\*.*") $toReturn = $toReturn & search($search2, $var & "\" & $file) EndIf WEnd return $toReturn EndFunc Edited August 27, 2008 by Prab FolderLog GuiSpeech Assist Share this post Link to post Share on other sites
dimchik 0 Report post Posted August 27, 2008 Thnks let me try. Share this post Link to post Share on other sites
dimchik 0 Report post Posted August 27, 2008 Is it possible to controll not to scan files only folders and only 3 levels deep as i have over 70million files ill be listing for 5 days. Share this post Link to post Share on other sites
Prab 0 Report post Posted August 27, 2008 $search = FileFindFirstFile($var & "\*.*") and If StringInStr($attrib, "D") Then Controls what kinds of files/folders it scans. "D" stands for Directory. -------------- Edit Func search($search, $var) to be something more like Func search($search, $var, $depth) If ($depth > 3) then return $toReturn EndIf( and toReturn = $toReturn & search($search2, $var & "\" & $file) to be more like toReturn = $toReturn & search($search2, $var & "\" & $file, $depth + 1) FolderLog GuiSpeech Assist Share this post Link to post Share on other sites