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

RE: Folder watch using wild card by tlavedas

tlavedas
Mon Jun 21 12:26:02 CDT 2004

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
>
>
>
>
>

Re: Folder watch using wild card by Tony

Tony
Mon Jun 21 13:43:22 CDT 2004

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
> >
> >
> >
> >
> >



Re: Folder watch using wild card by Tony

Tony
Mon Jun 21 16:32:56 CDT 2004

While I don't actually want a command window to come up in production use,
it does provide good feedback. I made your suggested changes and verified
that a file does exists in the dir but the ValidateFile function still
returns False and the command windows reports cannot find file. The problem
must be elsewhere. Don't know if this is necessary but I also tried calling
the subroutine with triple quotes around the dir and the file name. No
change except the dir fails to validate. I also tried using the exact name
of the file without the wildcard and still ValidateFile comes back false.

The original ValidateFile function I used works if looking for an exact
file name but doesn't like the wildcard. But of course the files will always
have varying names.

I am on WinXP Pro talking to an SBS2000 server. Just using notepad to edit
the script. I don't know if there are any other envirmonmental variables
that could be causing the problem.

Thanks for your help so far, I hope I am nost screwing up you suggestions
somehow. Here is another copy of the full script. I made some other
changes unrelated to the ValidateFile function.

Thanks

'********************START****************

Set System = CreateObject("Scripting.FileSystemObject")

Call WatchFolder("J:\Documents\Received Faxes\","Fax*.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

Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")

BtnCode = WshShell.Popup("New fax(es) in the Received Faxes folder." &
vbcr & vbcr & "Do you want to view them now?", 5, "New Fax", 4 + 32)
Select Case BtnCode
case 6
WshShell.run "explorer.exe J:\Documents\Received Faxes\",4
End Select
Set WshShell = Nothing

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)

With CreateObject("Wscript.Shell")
iRes = .Run("%comspec% /k dir /b " & FiletoValidate, 1, True)
ValidateFile = (iRes = 0)
End With

msgbox ValidateFile

End Function


'Function ValidateFile(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

'********************END****************

"Tom Lavedas" <tlavedas@hotmail.remove.com> wrote in message
news:890A2FF2-4FE8-4FE8-8F87-2D79F45D710E@microsoft.com...
> Funny, I checked it on a network drive with subfolders and it worked
perfectly for me.
>
> Try changing the /C parameter on the Run line to /K and the zero to 1 to
see what is happening in the console window of that subprocess.
Specifically the ValidateFile routine should look like this ...
>
> Function ValidateFile(FiletoValidate)
>
> With CreateObject("Wscript.Shell")
> iRes = .Run("%comspec% /k dir /b " & FiletoValidate, 1, True)
> ValidateFile = (iRes = 0)
> End With
>
> End Function
>
> If there are no matching files, you should see the message 'File not
found', otherwise it should show the matching file name(s) followed by a
standard command prompt (as in 'J:\Documents\Received Faxes>' - no quotes).
If it says anything else - or nothing, then that will indicate the process
is failing there. Type EXIT followed by the Enter key to close the window.
>
> If no window opens then there is some kind of coding error (typo or
unexpected line wrapping).
> --
> Tom Lavedas
> ===========
>
>
> "Tony Vrolyk" wrote:
>
> > 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
> > > >
> > > >
> > > >
> > > >
> > > >
> >
> >
> >








Re: Folder watch using wild card by Tony

Tony
Wed Jun 23 16:16:26 CDT 2004

Well I think I figured out the problsm. Need to refer to the dir using DOS
friendly name.

instead of
Call WatchFolder("J:\Documents\Received Faxes\","Fax*.TIF")

I used
Call WatchFolder("J:\Documents\Receiv~1\","Fax*.TIF")

and it worked


"Tony Vrolyk" <tvrolyk at mlhg dot net> wrote in message
news:%23JPJ3g9VEHA.3120@TK2MSFTNGP12.phx.gbl...
> While I don't actually want a command window to come up in production use,
> it does provide good feedback. I made your suggested changes and verified
> that a file does exists in the dir but the ValidateFile function still
> returns False and the command windows reports cannot find file. The
problem
> must be elsewhere. Don't know if this is necessary but I also tried
calling
> the subroutine with triple quotes around the dir and the file name. No
> change except the dir fails to validate. I also tried using the exact name
> of the file without the wildcard and still ValidateFile comes back false.
>
> The original ValidateFile function I used works if looking for an exact
> file name but doesn't like the wildcard. But of course the files will
always
> have varying names.
>
> I am on WinXP Pro talking to an SBS2000 server. Just using notepad to edit
> the script. I don't know if there are any other envirmonmental variables
> that could be causing the problem.
>
> Thanks for your help so far, I hope I am nost screwing up you suggestions
> somehow. Here is another copy of the full script. I made some other
> changes unrelated to the ValidateFile function.
>
> Thanks
>
> '********************START****************
>
> Set System = CreateObject("Scripting.FileSystemObject")
>
> Call WatchFolder("J:\Documents\Received Faxes\","Fax*.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
>
> Dim WshShell, BtnCode
> Set WshShell = WScript.CreateObject("WScript.Shell")
>
> BtnCode = WshShell.Popup("New fax(es) in the Received Faxes folder."
&
> vbcr & vbcr & "Do you want to view them now?", 5, "New Fax", 4 + 32)
> Select Case BtnCode
> case 6
> WshShell.run "explorer.exe J:\Documents\Received Faxes\",4
> End Select
> Set WshShell = Nothing
>
> 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)
>
> With CreateObject("Wscript.Shell")
> iRes = .Run("%comspec% /k dir /b " & FiletoValidate, 1, True)
> ValidateFile = (iRes = 0)
> End With
>
> msgbox ValidateFile
>
> End Function
>
>
> 'Function ValidateFile(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
>
> '********************END****************
>
> "Tom Lavedas" <tlavedas@hotmail.remove.com> wrote in message
> news:890A2FF2-4FE8-4FE8-8F87-2D79F45D710E@microsoft.com...
> > Funny, I checked it on a network drive with subfolders and it worked
> perfectly for me.
> >
> > Try changing the /C parameter on the Run line to /K and the zero to 1 to
> see what is happening in the console window of that subprocess.
> Specifically the ValidateFile routine should look like this ...
> >
> > Function ValidateFile(FiletoValidate)
> >
> > With CreateObject("Wscript.Shell")
> > iRes = .Run("%comspec% /k dir /b " & FiletoValidate, 1, True)
> > ValidateFile = (iRes = 0)
> > End With
> >
> > End Function
> >
> > If there are no matching files, you should see the message 'File not
> found', otherwise it should show the matching file name(s) followed by a
> standard command prompt (as in 'J:\Documents\Received Faxes>' - no
quotes).
> If it says anything else - or nothing, then that will indicate the process
> is failing there. Type EXIT followed by the Enter key to close the
window.
> >
> > If no window opens then there is some kind of coding error (typo or
> unexpected line wrapping).
> > --
> > Tom Lavedas
> > ===========
> >
> >
> > "Tony Vrolyk" wrote:
> >
> > > 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
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>
>
>
>
>