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 / Help with IF Condition...
Power Automate
Answered

Help with IF Condition for File Name Filtering in Power Automate Desktop

(1) ShareShare
ReportReport
Posted on by 7
Hi All,
 
I'm having trouble getting the IF condition to work in Power Automate Desktop. Attached the Flow Screenshot FYR .
 
Goal:
I want to check if a file in my Downloads folder contains both:
  • A specific keyword: "InvoiceReconcileLogistics"
  • Today's date in the format yyyyMMdd (e.g., 20250707)
If the file name matches both conditions (e.g., "InvoiceReconcileLogistics 20250707.xlsx"), I want to move it to a folder on to my Desktop folder called "Logistics" from Download Folder
I've tried using the If CurrentListItem.Name Contains ${FileName} and CurrentListItem.Name Contains ${CurrentDate} conditions, but it doesn't seem to trigger correctly. I've confirmed that the CurrentDate variable is being set in the yyyyMMdd format.
 
Question:
Is there something I may be missing in the way I’m structuring the condition? Is it better to use a single combined string or a different approach?
Any guidance or tips would be greatly appreciated!
 
Thanks in advance!
Flow Screenshot.png
I have the same question (0)
  • Verified answer
    stampcoin Profile Picture
    5,146 Super User 2026 Season 1 on at
    @unni1- Hi,
    Your flow looks good, 
    1. Ensure no extra spaces exist when setting variables.
    2. Use logging or display messages to debug the exact values at runtime.
    3. Always verify the downloaded filenames match your expected format exactly.
    Maybe try to combine keyword and date into one string explicitly,
    for example ExpectedFileName = ${FileName} ${CurrentDate}.
     
    pseudocode:
    1. Get current date and time (CurrentDateTime)
    2. Convert datetime to text (yyyyMMdd → FormattedCurrentDate)
    3. Set variable CurrentDate = FormattedCurrentDate
    4. Set variable FileName = "InvoiceReconcileLogistics"
    5. Set variable ExpectedFileName = "${FileName} ${CurrentDate}"
    6. Get files from Downloads folder (*.xlsx) into DownloadFiles
    7. For each CurrentListItem in DownloadFiles:
         - If CurrentListItem.Name Contains ${ExpectedFileName}:
             - Move file to "Logistics" folder on Desktop
     
     
  • Verified answer
    VishnuReddy1997 Profile Picture
    2,656 Super User 2026 Season 1 on at
    Hi @unni1-,
     
    Please find the solution.
     
     
    Script :
    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''yyyyMMdd''' Result=> FormattedDate
    Folder.GetFiles Folder: $'''C:\\Users\\HP\\OneDrive\\Desktop\\1992''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> FilesList
    LOOP FOREACH CurrentItem IN FilesList
        IF (Contains(CurrentItem.Name, 'InvoiceReconcileLogistics') AND Contains(CurrentItem.Name, FormattedDate)) = $'''True''' THEN
            Display.ShowMessageDialog.ShowMessage Message: $'''yes''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
        ELSE
            Display.ShowMessageDialog.ShowMessage Message: $'''NO''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
        END
    END
    
     
     
    Regards,
    Vishnu Reddy

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard