WinBatch Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: Mike Burgoon on July 11, 2013, 12:24:34 pm

Title: Directory Help
Post by: Mike Burgoon on July 11, 2013, 12:24:34 pm
hello, I am trying to get a full list of all directories and subdirectories off of a unc share. What is the best way to go about this. I have tried an example using srchInit from the tech support site, but that does not work for some reason. I also tried with fafopen and faffind, but it was PAINFULLY slow on a large set of dirs. worked fine on a small set, but the large set ran forever and I finaly just killed the process.

Basically, I am looking for output to be similar to a "dir s:\*.* /s /b /A:D" except I need unc share instead of s:\


srchinit code below that does not work:

; get directories from source location
log ("**********")
log ("Getting Directory List...")
TopSrchDir = "%src%\"
nHandle = srchInit(TopSrchDir,"XXXXXXXX.XXXX","", 0,48) ;srchinit(path, mask, strings, exclude mask, flags )
while 1
   If xxx=="" then break
   dir_list = ItemInsert(xxx, -1, dir_list, @TAB)
log ("Completed")
FilePut("%inst%dirlist.txt", dir_list)

Title: Re: Directory Help
Post by: Deana on July 11, 2013, 12:41:41 pm
I recommend using the File and Folder extender it is very fast. Plus it has a flag to ignore files and only look at directories. One other thing that will speed it up is to write out the file name each time instead of building a big string then writing it out. Here is a code sample that should get you started:
Code: Winbatch
outputfile = Dirscript():'dirlist.txt'
;handle = fafOpen('\\?\UNC\Server64\Outbound', '*', 8|16) ; To specify an extended-length path, a maximum path of 32,767 characters, use the "\\?\" prefix.  
handle = fafOpen('\\Server64\Outbound', '*', 8|16)
nCount = 0
BoxOpen('Directories', '')
filehandle = FileOpen( outputfile, 'Write')
While 1
   sFound = fafFind( handle )
   If sFound == '' Then Break
   nCount = nCount + 1
   BoxTitle( nCount )
   BoxText( sFound )
   FileWrite( filehandle, sFound )
fafClose( handle )
FileClose( filehandle )
Run( outputfile, '' )
Title: Re: Directory Help
Post by: Mike Burgoon on July 11, 2013, 01:28:57 pm
thanks, that did the trick.  I did one before with FAF, but it ran a REALLY long time.  writing the output to the file as it goes seems to work much faster now.