If statement: Check if folder does NOT exist.

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.

If statement: Check if folder does NOT exist.

Postby acascianelli » Tue Nov 19, 2013 3:51 pm

Looking to write a small if statement to see if a folder exists, and if it does not go ahead a create it. One caveat is that the foldername contains a variable. Here's what I got so far but it isn't working. Would appreciate a little assistance...

Code: Select all
<timestamp version="1.0">
     <format outputVariable="currentDate" pattern="yyyyMMdd" />
</timestamp>

<if label="if: folder exists" condition="${FileInfo(&apos;/opt/Linoma_Software/GoAnywhere_Services/share/webdocs/MDT/Datamail/Archived/${currentDate}&apos;):exists == false}" logLevel="debug">
     <mkdir dir="/opt/Linoma_Software/GoAnywhere_Services/share/webdocs/MDT/Datamail/Archived/${currentDate}" version="1.0" />
</if>
acascianelli
 
Posts: 4
Joined: Fri May 17, 2013 1:17 pm

Re: If statement: Check if folder does NOT exist.

Postby Support_Rick » Tue Nov 19, 2013 4:10 pm

Tony,

Just remove the IF statement and just do the MKDIR. Just change it to ignore the error if the folder already exists. That way you'll see the MKDIR in the job log, but it will tell you if the folder was created or not. And, more importantly, continue processing either way, by making sure the folder already exists or creating when needed.

Code: Select all
<mkdir dir=".../Archived/${currentDate}" onError="continue" version="1.0" />
Rick Elliott
Sr. Product Specialist
(402) 944.4242
(800) 949-4696
Support_Rick
Support Specialist
 
Posts: 200
Joined: Tue Jul 17, 2012 2:12 pm

Re: If statement: Check if folder does NOT exist.

Postby acascianelli » Tue Nov 19, 2013 4:15 pm

Thanks Rick.

I was trying to be fancier than I needed to be I guess. Seems to be a common problem I'm running into today...
acascianelli
 
Posts: 4
Joined: Fri May 17, 2013 1:17 pm

Re: If statement: Check if folder does NOT exist.

Postby acascianelli » Wed Nov 20, 2013 11:15 am

Is there any way to have the error message in the job log suppressed in the event that the folder is already present?
acascianelli
 
Posts: 4
Joined: Fri May 17, 2013 1:17 pm

Re: If statement: Check if folder does NOT exist.

Postby Support_Rick » Wed Nov 20, 2013 11:30 am

You can suppress the message by changing the loglevel ... like so.

Code: Select all
<mkdir label="Create Dirs" dir="...\MyDir\MySubDir" version="1.0" logLevel="silent" onError="continue" />


But, this would remove it altogether. Normal and Verbose might give you different values. Might want to check them out as well.
Rick Elliott
Sr. Product Specialist
(402) 944.4242
(800) 949-4696
Support_Rick
Support Specialist
 
Posts: 200
Joined: Tue Jul 17, 2012 2:12 pm


Return to Community Forum

Who is online

Users browsing this forum: No registered users and 1 guest