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.
5 posts
Page 1 of 1
- Posts: 4
- Joined: Fri May 17, 2013 1:17 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('/opt/Linoma_Software/GoAnywhere_Services/share/webdocs/MDT/Datamail/Archived/${currentDate}'):exists == false}" logLevel="debug">
<mkdir dir="/opt/Linoma_Software/GoAnywhere_Services/share/webdocs/MDT/Datamail/Archived/${currentDate}" version="1.0" />
</if>
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
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.
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
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
- Posts: 4
- Joined: Fri May 17, 2013 1:17 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...
I was trying to be fancier than I needed to be I guess. Seems to be a common problem I'm running into today...
- Posts: 4
- Joined: Fri May 17, 2013 1:17 pm
Is there any way to have the error message in the job log suppressed in the event that the folder is already present?
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
You can suppress the message by changing the loglevel ... like so.
Code: Select all
But, this would remove it altogether. Normal and Verbose might give you different values. Might want to check them out as well.<mkdir label="Create Dirs" dir="...\MyDir\MySubDir" version="1.0" logLevel="silent" onError="continue" />
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
5 posts
Page 1 of 1