web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / IF File Does Not Exist
Power Automate
Unanswered

IF File Does Not Exist

(0) ShareShare
ReportReport
Posted on by Super User 2024 Season 1

I would like to check if a file does exist in the folder then launch excel and do the rest of the script, but if the does NOT exist continue with the script to find the next file, if does exist do your things, if not continue to the next code.

For now, if the file does NOT exist in the folder, the script will break because when excel launch it will throw an error cannot find the file in folder path. But I need for the script to continue because the customer did not send their file.  I already send a second request to the customer at the beginning of the script, if they did not send it, I want to script to continue without breaking.  This is what I have.  Please show me the step in PAD (Power Automate Desktop) so I can see it.  Thanks an advance!

TTC_0-1684529254625.png

 

I have the same question (0)
  • CFernandes Profile Picture
    8,504 Most Valuable Professional on at

    @TTC You can simply use "If file exists" and provide a file path...

     

    CFernandes_0-1684531983930.png

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

     

    P.S. take a look at my blog here and like & subscribe to my YouTube Channel thanks.

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    If you are doing this for a bunch of files, the files probably shouldn’t be hard keyed. 

    usually we have something along the lines of:

     

    Get Files to %Files%
    For Each %CurrentItem% in %Files%
        Launch Excel

        ‘Do other things

        Save and Close Excel

    End (for each)

     

    if you really want to continue the way you are doing:

     

    if file exists %filepathandname%
        ‘Do actions

    end(if)

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    I am not sure if understand either the solution.  I know if the file does exist in the folder, the script will continue do whatever I am asking it to do.  But, I want when the file DOES NOT EXIST, I want the script to continue on Line# 90 to launch the next file if it is find it (of course, I will put another 'if file does not exist' statement),  again if it's NOT FIND IT, go the next script.  After the IF file exists statement, I need an 'Function' to jump all the actions and to continue with the next code.  As I expected, the script break because there's no file in the folder.  But I do know, it's because the customer did not send their file. For that reason. I want the script to continue without breaking.

    This is what I have, please correct me and make any changes you think is the best and let me see your step in PAD.

     

    TTC_0-1684551854637.png

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @TTC 

     

    Instead of using harcoded file exists action, why don't you put all file path in a list and then iterate through it and then if file exists, do the required actions

     

    Refer this flow design 

     

    Nived_Nambiar_0-1684553651982.png

     

    (Note: file seperator becomes \\ as you see in list even if you type \ in set variable action )

     

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    Niced said the same thing I did, but if you are intent on just skipping the items when it doesn’t exist, then do the second one I posted:

     

     

    If file exists

         â€˜Do all actions here

    End(If)

     

    Put everything from launch excel to save and close excel in the IF statement, and that way, if the file doesn’t exist, it won’t perform any of those steps and will skip down to END. 

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Hello Both,

    I know I made a mistake somewhere, but I am try to match what Nived sent, but I am getting an error on my end.

    When I try the script with no file, it skips and goes to the end, but when I try with a file in the folder, it does the same thing.  Something I did and cannot figure it out.  Can you help please?  Below is the error when I try to match it.

     

    TTC_0-1684601769581.png

    TTC_1-1684601899040.png

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @TTC 

     

    You should intialize the list like this 

     

    Nived_Nambiar_0-1684633958895.png

     

     

    without using %% , it would be considered as string

     

    Also one more mistake i found in your code is the loop item 

    Nived_Nambiar_1-1684634034692.png

     

    see in your case, you are taking Files_List as loop iteration item , it is wrong. You should design like below 

     

    Nived_Nambiar_2-1684634094410.png

     

     

    Hope it helps !

     

     

     

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    @Nived_Nambiar is right. You are just missing your brackets and commas that turn your variable into a list. Good luck. 

  • TTC Profile Picture
    Super User 2024 Season 1 on at

    Hello Guys,

    Ok, now I think I match everything, but it won't launch the excel file.  It skips everything to go to the end.

     

    TTC_0-1684703320675.png

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @TTC 

     

    There is some issue in how you define the variables within list. 

     

    see below 

    Nived_Nambiar_0-1684720756044.png

     

    Nived_Nambiar_1-1684720780287.png

     

     

    Hope it helps !

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 378

#2
Valantis Profile Picture

Valantis 329

#3
David_MA Profile Picture

David_MA 283 Super User 2026 Season 1

Last 30 days Overall leaderboard