Forum Discussion

munish's avatar
munish
New Contributor
6 years ago

File exists or not

I am designing a pipeline where I need to put a condition.
If (File exists)
then run snap 1
else
run snap 2

I want to achieve this with snaplogic pipeline. please help

3 Replies

  • dimche_saveski's avatar
    dimche_saveski
    New Contributor III

    Hello @munich

    1 way of achieving that scenario is by using Snaplogic List snap and downstream Router snap.
    Snaplogic List snap will be configured to list just file assets, and then check if your desired file exists( in the Router snap).

    Best Regards
    Dimche Saveski

  • christwr's avatar
    christwr
    Contributor III

    If the problem is doing something else when no data to trigger your downstream snaps (router, etc.) you could look at patterns in some of the “when no data” threads like below:

    Basically create some fake data, join it with your actual data (or missing data) from your directory browser, then check if you actually had data or not in the downstream router snap (if/else).

  • Supratim's avatar
    Supratim
    Contributor III

    @munish - Use directory browser snap and dis-select "ignore empty result " , then use mapper and check hasOwnProperty() to check “Name” is available or not. If not then snap2 else snap1