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 / How to rename a file w...
Power Automate
Answered

How to rename a file with a changing filename from an FTP folder

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I'm trying to use Power Automate desktop to create a flow that will allow me to connect to an FTP folder, rename a file and then move that file to a sharepoint location.

Now I can connect to the FTP and I can see all my files there, the problem is that the filename that I want to rename will be different every day as it has a date extension. "XXXXX_ddmmyy_hhmmss.xlsx" 

 

How can I make sure that my flow selects the correct file from today in order to rename it? Assuming there could be multiple files in the folder still from previous days.

I have the same question (0)
  • Verified answer
    VJR Profile Picture
    7,635 on at

    Hi @Anonymous 

     

    Below is the pseudo logic.

    • format today's date in a variable in the required format you need ie; ddmmyy

     

    • When you loop through the files you can do a wild card check to look for a file that has a pattern as

    XXXXX_<your_above_date_variable>_hhmmss.xlsx

     

    Without taking a look I am thinking the wild card to be used is 

    *_<your_above_date_variable>*.xlsx

     

    The first * would mean anything before the date and the second * would mean anything after the date, and then we have given the extension.

    The angular brackets < and > are not to be used. I am just using it for explanation purpose as a placeholder.

     

    • If found go ahead and rename it.

     

     

    This is in a windows file folder not on a FTP but just to give you an example

     

    If the files in folder is as below

    VJR_0-1633700731699.png

    Then wild card results into just that one file

    VJR_1-1633700846216.png

     

    If you do not have an option to do a wild card search in the FTP code you are doing then read every file name one by one and check whether it matches this pattern.

     

    VJR_2-1633701699771.png

     

    After running the Display message showed that the matching date was found at position 5 (starts at 0).

    abcd_081021_012345.xlsx

     

    VJR_3-1633701777384.png

     

    If the value returned is less than 0 then it is not found and go to the next file.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

     

    Doesn't seem to work. The flow is running, but it seems as if the flow doesn't detect the file if I use the variable and wildcard. If i use teh full name of todays file without using the variable and wildcard it does find it and download it. So something about that date variable and wildcard makes it so the flow doesn't find the file.

    bvanbruw_0-1633702819962.png

    bvanbruw_1-1633702876585.png

     

     

  • VJR Profile Picture
    7,635 on at

    Hi @Anonymous, I have edited the post and added some PAD screenshots. That will help you to change the date format . 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Nevermind,

     

    You're inital solution works like a charm. It also accepts the wildcard*. The issue was that I incorrectly converted the DateTime to text. I used yyyymmd instead of yyyMMdd.

    Thanks for the solution and support!

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 169

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard