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 download...
Power Automate
Answered

How to rename downloaded xls-file with changing filename (XXXX_yyyddmm.xlsx)? xxxx = constant; date changes)???

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi there, 

 

I am facing the following problem: 

 

- I am maintaining a xls-report that needs to be updated with the latest data every month

- for that, I have to download some data (also xls) from a website (which I have automated via Power Automate)

- the download file name consists of two parts, e.g. "download_20220927.xlsx" - part 1 "download_" never changes, part II "20220927" changes always according to the current date when I retrieve the data

- in order that the query in my xls-report works, I need to rename the download to a standardized name, e.g. "Input_data_report.xlsx"

- And there is exactly my challenge: How do I rename a file whose name changes from month to month (or rather depending on the date when I download the file)?

 

Current approach (which doesn't work): 

- I added the action "Click on UI element in window" and saved the current file name 

- that works for this particular download, but the next download (e.g. tomorrow or next month) won't work, as the name of the downloaded file changes, hence PA doesn't recognize the file anymore 

- The plain "rename" functions forces me to choose only one particular file (=file name)  

 

Highly appreciate your support here!!! 

Thanks and all the best from Berlin

Philipp 

  • PhilipTreacy Profile Picture
    120 on at

    Hi @Anonymous 

     

    Try using Click link on web page and choosing a Right Click 

    padrc.png

     

     

    You can then click on the Save as link and complete the name of the file as you want it to be saved.

     

    Regards

     

    Phil

  • VJR Profile Picture
    7,635 on at

    Form a string that will be equal to the file name to be searched.

    Output variables after running the below steps.

    VJR_3-1664339191057.png

     

    Now your MyFileName variable has the name to be looked for as per today's date-

    Pass it to the rename action.

     

    Make sure the FilePathHere has the \ in the path.

    ...Of the format C:\Test\download_20220928.xlsx

     

    VJR_4-1664339275274.png

     

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @PhilipTreacy! But this doesn't work as I do not have access directly to the file but only over a html button that triggers the download. 

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @VJR - Let me try this. I'll keep you posted! 

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Unfortunately this approach is also not solving it, as the file name of download is in fact FileName_yyyddmmhhmmss.xlsx (--> so also includes hours, minutes, and seconds) - and that would be impossible to match with a string I guess... 

     

    Would it be possible to create a variable that always selects the file in a folder that has been "last modified"? Or maybe to look for a file that contains "FileName*.xlsx" or something like that?  

  • Verified answer
    VJR Profile Picture
    7,635 on at

    You can use Get Files which has an option to sort by the modified or created date and then get just the first item of that list

    %Files[0]%

  • Verified answer
    Pavel_NaNoi Profile Picture
    1,074 on at

    If I understood this correctly, you can simply:

     

    Use a "parse text" action after a get files activity, with the following regex:

    "download_\d+" without the quotes,

    store the match into a variable and then use that match for the rename file action.

     

    If there are multiple new download_###### files where you're downloading then make sure to uncheck "First occurrence only" in the "Parse text" action, and do a for each on the list of matches you get.

     

    IF you have outdated download_###### files in the same place as the new download_##### file, then:

    use this regex instead: "(?<=download_)\d+" this will get you just the number after "download_" use this number and convert it to date time with the convert to datetime action, from there its just a matter of using if logic, e.g. only select this download file if its date isn't < than today or something similar.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    sabei_sabei_0-1664376805085.png

    The download arrives in the format "TimeAndExpenseDetails_yymmddhhmmss.xlsx. which I can select/find through searching for "TimeAndExpense*". Saving this in a variable, I can rename the file (to TimeAndExpensesDetails.xlsx) and move it into the location where the original report pulls the query from the newly replaced file. Problem solved!

     

    Thanks all! That did the job! 

     

     

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 233 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 178

Last 30 days Overall leaderboard