I have the following script for SQL DTS
dim filesys, filesys1newfolder, mydate,s,mymonth,r,t,f, x
x = 0
f = "C:\February\02-12-2003\bsusa.txt"
set filesys1=CreateObject("Scripting.FileSystemObject"
If Not filesys1.FileExists(f) Then
MsgBox ("A file '" & f & "' does not exist"
x=1
goto exit
Else
MsgBox ("A file '" & f & "' already exists"
End If
t = DatePart("m", Now)
mymonth = MonthName( t , False )
myDate = FormatDateTime(Now, vbshortdate)
'Msgbox mymonth
r = "C:\" & mymonth
set filesys=CreateObject("Scripting.FileSystemObject"
If Not filesys.FolderExists(r) Then
newfolder = filesys.CreateFolder(r)
End If
s= r & "\" & Replace(mydate, "/","-"
'msgbox s
set filesys=CreateObject("Scripting.FileSystemObject"
If Not filesys.FolderExists(s) Then
newfolder = filesys.CreateFolder(s)
MsgBox ("A new folder '" & newfolder & "' has been created"
Else
MsgBox ("A folder '" & s & "' already exists"
End If
Exit:
IF x = 0 then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End if
How can I get the script to stop from excuting when the file that is trying to find does not exist. The goto statement I found out does not work in VBScript like it does in VB
Any help is appreciated!
dim filesys, filesys1newfolder, mydate,s,mymonth,r,t,f, x
x = 0
f = "C:\February\02-12-2003\bsusa.txt"
set filesys1=CreateObject("Scripting.FileSystemObject"
If Not filesys1.FileExists(f) Then
MsgBox ("A file '" & f & "' does not exist"
x=1
goto exit
Else
MsgBox ("A file '" & f & "' already exists"
End If
t = DatePart("m", Now)
mymonth = MonthName( t , False )
myDate = FormatDateTime(Now, vbshortdate)
'Msgbox mymonth
r = "C:\" & mymonth
set filesys=CreateObject("Scripting.FileSystemObject"
If Not filesys.FolderExists(r) Then
newfolder = filesys.CreateFolder(r)
End If
s= r & "\" & Replace(mydate, "/","-"
'msgbox s
set filesys=CreateObject("Scripting.FileSystemObject"
If Not filesys.FolderExists(s) Then
newfolder = filesys.CreateFolder(s)
MsgBox ("A new folder '" & newfolder & "' has been created"
Else
MsgBox ("A folder '" & s & "' already exists"
End If
Exit:
IF x = 0 then
Main = DTSTaskExecResult_Success
Else
Main = DTSTaskExecResult_Failure
End if
How can I get the script to stop from excuting when the file that is trying to find does not exist. The goto statement I found out does not work in VBScript like it does in VB
Any help is appreciated!