14. VbScript | How to Check if File & Folder Exists

So you can use VbScript to move and copy files around on your computer. But if the specific file or folder does not exist, you are going to get an error. So in this tutorial I am going to show you how to check before this error occurs. First we need to start with a New CreateObject Command:

Add to the end of .FileExists or .FolderExists command:

Let’s streamline the VbScript:

Choose an image from your Desktop:

desktop_cat_icon

Right Click and choose Properties. From there copy the Location:

a2

Paste Location into fso.FileExist(” “) with the filename of the picture:

Now we need to make a Feedback Loop that tells us whether the file exists or not:

Output:

a3

The Feedback Loop that tells us whether the folder exists or not:


What's Your Opinion?