Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

exiting a vbscript

Posted on 2014-03-13
7
Medium Priority
?
254 Views
Last Modified: 2014-03-13
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
0
Comment
Question by:adirisin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39926173
Hi,

pls try

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(path)) = False Then
WScript.Quit
End If

Open in new window

Regards
0
 

Author Closing Comment

by:adirisin
ID: 39926209
Thanks so much Rgonzo1971, it's working as expected.

Thanks again!
0
 

Author Comment

by:adirisin
ID: 39926447
Hi Rgonzo1971,

Actually, the script exits if there are no files; however, it is exiting even if there are files. Please advise.

Thanks!
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39926504
Then try

Path = "c:\*.xls*" ' looking for .xls* files

If Dir(Path) = "" Then
WScript.Quit
End If

Open in new window

Regards
0
 

Author Comment

by:adirisin
ID: 39926579
Hey,

The query i wrote is:

Path = "C:\Users\aditya.kumar.vaish\Downloads\Trial_Runs\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.
0
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39926681
Hi,
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

Open in new window

EDIT Code corrected

Regards
0
 

Author Comment

by:adirisin
ID: 39927055
Hi Rgonzo1971,

That's perfect!! It is doing exactly what I wanted. Thanks so much !!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question