Re: Folder watch using wild card

From: Tony Vrolyk (tvrolyk)
Date: 06/21/04


Date: Mon, 21 Jun 2004 13:43:22 -0500

Thanks but I am still not getting what I expect. I put a msgbox line in
there to give me feedback on the value of ValidateFile and it seem to return
False regardless of the presence of any *.TIF files. I am not a script
export, just one of the copy and use folks so I can't troublshoot on my own
to well.

If it helps - the folder I am watching is a on a network share, as you can
tell. The files are always 11 characters plus extension in all caps. They
always begin Fax. So a sample file name might be Fax000001fd.TIF

Any more help would be appreciated.
Tony

"Tom Lavedas" <tlavedas@hotmail.remove.com> wrote in message
news:E41645DB-EC2A-4300-AEFD-75EB03D773CD@microsoft.com...
> The following rewrite of the ValidateFile routine is a generalized
'wildcard' processor, that does what you want ...
>
> Function ValidateFile(FiletoValidate)
> Dim iRes
> With CreateObject("Wscript.Shell")
> iRes = .Run("%comspec% /c dir /b " & FiletoValidate, 0, True)
> ValidateFile = (iRes = 0)
> End With
> End Function
>
> Tom Lavedas
> ===========
>
> "Tony Vrolyk" wrote:
>
> > I found this posting which had a script I could use for watching a
folder
> >
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&selm=7vpb87%243dvo%241%40newssvr04-int.news.prodigy.com
> >
> > I have tweaked it for my needs but don't know how to use it to watch for
any
> > files with a particular extension, in this case *.tif. I have the
following
> > line calling the procedure but it is not working. How do I handle this?
> >
> > Call WatchFolder("J:\Documents\Received Faxes\","*.TIF")
> >
> > Thanks
> > Tony
> >
> >
> > full modified script
> > ******************************************
> >
> > Set System = CreateObject("Scripting.FileSystemObject")
> >
> > 'Substitute the complete path of the folder to be watched for the
> > 'parameter Arg1. Substitute the complete path of folder X for
> > 'the parameter Arg2. Substitute the complete path of folder Y
> > 'for the parameter Arg3. Substitute the name of the file to be
> > 'moved to folder X for the parameter Arg4. Substitute the name
> > 'of the file to be moved to folder Y for the parameter Arg5.
> > 'Note that you don't have to specify the complete path of the file
> > 'names; you can pass just the filename as an argument. All parameters
> > 'must be passed as strings, and they must be passed in the exact
> > 'order specified above in order for this routine to work correctly.
> >
> > Call WatchFolder("J:\Documents\Received Faxes\","*.TIF")
> > Wscript.Quit
> >
> >
> > Sub WatchFolder(FolderToWatch,FiletoWatch)
> > Dim FileNameX
> >
> >
> > 'Check to ensure that the folder names that were passed as
> > 'arguments actually exist. If not, give error message and exit.
> > If ValidateFolder(FolderToWatch) = False Then Exit Sub
> >
> > 'Adds trailing backslash to folder paths if neccesary.
> > FolderToWatch = AddBackslash(FolderToWatch)
> >
> > FileNameX = FolderToWatch & System.GetFileName(FiletoWatch)
> > If ValidateFile(FileNameX) = True then
> > if msgbox("New fax(es) in the Received Faxes
> > folder.",vbyesno+vbquestion+vbdefaultbutton2,"New Faxes") = vbyes then
> > msgbox "ok"
> > end if
> > End if
> >
> > ' Set System = Nothing
> > ' Wscript.Sleep 300000 'Sleep for 5 minute.
> >
> > 'Subroutine starts a new instance of the running script and
> > 'terminates the current instance.
> > ' Set Shell = CreateObject("Wscript.Shell")
> > ' Shell.Run "wscript " & """" & Wscript.ScriptFullName & """"
> > ' Set Shell = Nothing
> > ' Wscript.Quit
> > End Sub
> >
> >
> >
> > Function ValidateFile(FiletoValidate)
> >
> > msgbox FiletoValidate
> > If System.FileExists(FiletoValidate) Then
> > ValidateFile = true
> > Else
> > ValidateFile = False
> > End If
> > End Function
> >
> >
> > Function AddBackslash(ThisFolderPath)
> > If Not Right(ThisFolderPath,1) = "\" Then
> > ThisFolderPath = ThisFolderPath & "\"
> > End If
> > AddBackslash = ThisFolderPath
> > End Function
> >
> >
> > Function ValidateFolder(FolderToCheck)
> > Const Message = " is not an existing folder on your"
> >
> > If Not System.FolderExists(FolderToCheck) Then
> > MsgBox FolderToCheck & Message & " system."
> > ValidateFolder = False
> > Else
> > ValidateFolder = True
> > End If
> > End Function
> >
> >
> >
> >
> >