WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

File Searcher
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Leading Dot in Directory Name

 Keywords:  Leading Dot in Directory Name

Question:

I believe I have found an error in the file Search Extender. The search does not recurse into a subdirectory if the subdirectlry name begins with a period (.).

Example - series of text files:

C:\Temp\testfil1.txt
C:\Temp\.test\testfil2.txt
C:\Temp\.test\TstInDot\testfil3.txt
Sample Code:
SrchFile = StrCat(SrchPath,"\",SrchMask)
SrchHandle = SrchInit (SrchPath,SrchMask,"","",16 + 8)
While @TRUE
NextFile = SrchNext(SrchHandle)
if NextFile == "" then Break ; No more files found
FileCount = FileCount + 1
RptLine = StrFix(StrCat(" ",FileCount)," ",7)
RptLine = StrCat(RptLine,NextFile)
FileWrite(RptHandle,RptLine)
endwhile
SrchFree(SrchHandle)
Using SrchMask = "test*.txt", when SrchPath = "c:\temp", returns:
1 c:\temp\testfil1.txt
When set to "c:\temp\.test" returns:
1 c:\temp\.test\testfil2.txt
2 c:\temp\.test\TstInDot\testfil3.txt
I am assuming whoever created the extender assumed that the only directory entries starting with a period would be (.) and (..). Unfortunately the authors of Eclipse did not follow that policy. Any chance of getting a fix? Or a workaround? I'm trying to search multiple developer workstations looking for license files to determine how many copies are in use and which versions are out there.

Answer:

Sorry looks like the File Searcher does infact ignore folders with a leading dot. That is considered an invalid folder name in Windows. The Windows explorer prevents you from creating a folder with a leading dot.

Is renaming (DirRename)the folder an option?

Here is a possible workaround. Note: this code is not completely debugged:

#DefineFunction UDFFileItemRecurse( dir, mask)
    ptr_filelist = PtrGlobal( filelist )

    Terminate(DirExist(dir)==@FALSE,"Eeep","Directory does not exist")
    ;make sure we have a full path or a UNC
    test=StrIndex(dir,":",0,@FWDSCAN) + (StrSub(dir,1,2)=="\\")
    Terminate(test==0,"Eeep","Full path must be specified for Dir")
 
    DirChange(dir)
    ;clean up passed paramters just in case
    If StrSub(dir,StrLen(dir),1) != "\" Then dir=StrCat(dir,"\")
    
  
    data = FileItemPath( mask )
	 if data != ""
		 if *ptr_filelist == -1
			 *ptr_filelist = data : @tab
		 else
		    *ptr_filelist = *ptr_filelist :  data : @tab
		 endif
	 endif

    ;get list of subdirectories
    dirlist=DirItemize("*.*")
    count=ItemCount(dirlist,@TAB)
    ;Process each subdirectory
    For xx=1 To count
       thisdir= dir : ItemExtract(xx,dirlist,@TAB)     
       UDFFileItemRecurse(thisdir,mask)
    Next
    Return 
#EndFunction


PtrGlobalDefine( filelist )
mask = '*.*'
dir = "c:\Temp"
UDFFileItemRecurse(dir,mask)

AskItemlist('', filelist, @tab, @unsorted, @single )

Another workaround is the good old Dir command. With /s and /b parameters you get a complete recursed list of all directories and files. /ad will restrict to directories only and /a-d will omit directories from the list. Just redirect the output to a file and read back into a variable using FileGet or FileRead in a loop.


Article ID:   W17374
File Created: 2017:07:28:13:58:29
Last Updated: 2012:05:10:08:51:14