adirisin
asked on
exiting a vbscript
Hi,
I have written a VB Script which scans a folder and moves the xlsx files to another folder ("input folder"), converts them into xls, invokes SAS, processes files and creates output. Once this is done, another script moves the files from "input folder" to an archive folder.
I wish to add a few lines to this script so that if there are no files in the folder, it should skip remaining pieces of code and exit the script.
Is it possible?
Regards,
Aditya
I have written a VB Script which scans a folder and moves the xlsx files to another folder ("input folder"), converts them into xls, invokes SAS, processes files and creates output. Once this is done, another script moves the files from "input folder" to an archive folder.
I wish to add a few lines to this script so that if there are no files in the folder, it should skip remaining pieces of code and exit the script.
Is it possible?
Regards,
Aditya
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Rgonzo1971,
Actually, the script exits if there are no files; however, it is exiting even if there are files. Please advise.
Thanks!
Actually, the script exits if there are no files; however, it is exiting even if there are files. Please advise.
Thanks!
Then try
Path = "c:\*.xls*" ' looking for .xls* files
If Dir(Path) = "" Then
WScript.Quit
End If
Regards
ASKER
Hey,
The query i wrote is:
Path = "C:\Users\aditya.kumar.vai sh\Downloa ds\Trial_R uns\AUTO MATCH INPUT\*.xls*"
If Dir(Path) = "" Then
WScript.Quit
End If
However, I am getting an error stating
Type mismatch: 'Dir'.
The Data is invalid.
The query i wrote is:
Path = "C:\Users\aditya.kumar.vai
If Dir(Path) = "" Then
WScript.Quit
End If
However, I am getting an error stating
Type mismatch: 'Dir'.
The Data is invalid.
Hi,
this should be better
Regards
this should be better
Path = "C:\Users\aditya.kumar.vaish\Downloads\Trial_Runs\AUTO MATCH INPUT\"
bFound = False
Set fso = CreateObject("Scripting.FileSystemObject")
Set oFolder = fso.GetFolder(Path)
For Each oFile In oFolder.Files
If oFile.Name Like "*.xls*" Then
bFound = True
End If
Next
if bFound = False Then WScript.Quit
EDIT Code correctedRegards
ASKER
Hi Rgonzo1971,
That's perfect!! It is doing exactly what I wanted. Thanks so much !!
That's perfect!! It is doing exactly what I wanted. Thanks so much !!
ASKER
Thanks again!