Automic Workload Automation

 View Only
  • 1.  Condtions

    Posted Dec 02, 2020 05:04 PM
    I am looking for a way to create a condition on a job to check a folder and if it is empty to skip the process flow. Has anyone came across a way to do this?​


  • 2.  RE: Condtions

    Posted Dec 02, 2020 07:22 PM
    We typically need to do this check against a windows folder, so I found a DOS script for doing the check and put it in a reusable UC4 job.  I pass it the folder name, a switch to tell it if it should count hidden files or not, and it either sets a return code of 0000 or 0100 to indicate if the folder is empty or not.
    Here is the guts of that process script;
    :if &HIDDENFILES# = "YES"
    : set &ATTSWITCH# = "/a"
    : print "Hidden files switch was turned on"
    :else
    : set &ATTSWITCH# = ""
    : print "Hidden files switch was turned off"
    :endif

    @echo off

    if not exist "&FOLDERNAME#" echo Could not find: "&FOLDERNAME#" & exit 200

    for /F %%i in ('dir /b &ATTSWITCH# "&FOLDERNAME#*"') do (
    echo Files exist in folder &FOLDERNAME# setting RC=0100
    exit 100
    )
    echo No files found in folder &FOLDERNAME# setting RC=0000
    exit 0


    ------------------------------
    Pete Wirfs
    SAIF Corporation
    Salem Oregon USA
    ------------------------------