Base de connaissances

How to check a directory exists from an XML Job

Hint Ref: 021310080003
Hint Date: 08/10/2013

Hint Details:

The Question was:

 

Is there a way to check a directory exists, from a XML job, like you can a file using <IfFileExists>?

The answer is:

Not directly. However, you can do a Directory Query, which returns the details of any files in a Directory and then just test for any records.  

If you search for all files matching '*.*', in addition to the file list, you will always get a single dot (representing the directory itself) and a double dot (representing the parent directory).

Thus an empty directory should always return 2 rows. See example below.


<Job autoclose="YES">
 <DirectoryQuery pattern="c:\temp\wibble\*.*">
   <IfAnyRows>
     <MessageDialog text="directory exists"/>
   </IfAnyRows>
   <IfNoRows>
     <MessageDialog text="directory does not exist"/>
   </IfNoRows>
 </DirectoryQuery>
</Job>