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

Miscellaneous

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

FileExist to Test Multiple Files in a Directory

Keywords: 	 multiple fileexist

Question:

I tried this code with File Exist...to see if the file is open it works:
   if FileExist ("i:\clients\bbdo\billing\index\key.dbf") == 2 then Message("Ah-ha !! ", "File is open in Read_Deny Mode")
   else Message ("oops", "File is close")
   exit
but when i try o check mutiple files in this Index directory like *.*
   if FileExist ("i:\clients\bbdo\billing\index\*.*") == 2 then Message("Ah-ha !! ", "File is open in Read_Deny Mode")
   else Message ("oops", "File is close")
   exit
it fails .. how can i check all 21 files in the directory that if they are open or not as it doesn't work with *.*

also... what is READ-DENY MODE ?

or any other approach ,,, besides wntuser fucntion ,, cuz to use that function have to have administrative rights...

Answer:

FileExist does not accept WildCards.

I'm thinking maybe you could try renaming the entire directory holding the files. If you can rename it, then nobody is accessing the files. Then you can update them, then rename the directory back. If anyone tries to access the files while the directory is renamed, then their request will fail.

Hopefully that is OK.


dirmake("i:\clients\bbdo\billing\New")
FileCopy ("c:\dean\index\*.*", "i:\clients\bbdo\billing\New", @FALSE)

indexfiles = FileItemize ("i:\clients\bbdo\billing\index\*.*")
numberofindex = ItemCount (indexfiles, @TAB)
message("", indexfiles)
message("", numberofindex)
DirChange ("i:\clients\bbdo\billing\index")
filescopied = 1

For filescopied = 1 to numberofindex
   thisfile=ItemExtract(filescopied,indexfiles, @Tab)
   i = FileExist (thisfile)
   if i == 2

while i == 2
   Message ("acckk","file is open damn :( %thisfile%")
   Delay (1)
   i = FileExist (thisfile)
   endwhile
endif

next

Message ("coolio","file is closed !! :) ")
DirChange("i:\")  ;<==need this to UNLOG Winbatch from that directory before the DirRename
Dirrename("i:\clients\bbdo\billing\index", "i:\clients\bbdo\billing\kool")
Dirrename("i:\clients\bbdo\billing\new", "i:\clients\bbdo\billing\index")
FileDelete("i:\clients\bbdo\billing\kool\*.*")
DirRemove("i:\clients\bbdo\billing\kool")
exit 


Article ID:   W14253
Filename:   Multiple FileExist Test.txt
File Created: 1999:10:26:11:22:50
Last Updated: 1999:10:26:11:22:50