Login Scripts

Checking for Existence of a File or Directory

Last reviewed: 08/03/2012

A useful technique is to check for the existence of a file or directory. You can then set actions on the result. This could be copying an update across, running an another application or just recording that something is installed. This can be achieved using the built in command line tools, as per the same script below.

In both examples the script will move on to the ":next" if the file or directory is found. You could change the "if exist" to "if not exist" if you want the script to react to something being missing as an alternative.

Checking for a file

In this example, the script is checking for a file called "content.txt" in the directory "example".

Checking for a Directory

This sample is checking for a directory called "content" which is a sub directory of "example"