Rename recent file in Downloads folder and move to specific folder with Power Automate Desktop

by

If you want to use Power Automate Desktop rename the most recent file in folder downloads follow with date and time, you can do it as follows step:

Get files in folder

Use Get files in folder action and set parameter as per below image, this setting will retrieve all file type in folder Downloads and sort it by creation time descending.

  • Folder: you can click folder icon and select your folder path such as “C:\Users\User\Downloads
  • File filter: You can use the wildcard character * to filter file types. For example, if you want to filter Excel files, you can use *.xlsx for Excel 2007 and later versions. If you want to apply multiple file filters, you can separate them with a semicolon, like *.xls;*.xlsx for Excel 97 through Excel 2003 and Excel 2007 and later versions
  • Advanced: Sort by Creation time, open toggle descending
Get files in folder
Click folder icon and select desired folder, File filter use * for retrieve all file type

This action will collect the files and store as a list of file in variable name as Files the most recent file will store in index 0.

Get files in folder
Advanced setting select sort by creation time and open toggle descending

Display message

Use Display message action for check the Index 0 in Files variable

To retrieve a specific item in a list, use the following notation: %VariableName[ItemNumber]%

Therefore the message to display will be %Files[0]%.

Display message
Type %Files[0]% in message to display for check value in list index 0 of Files variable

Get current date and time

Use Get current date and time action this action will store date and time in CurrentDateTime variable.

Get current date and time
System time zone will retrieve time zone in Control Panel

Rename file(s)

Use Rename file(s) action and set parameter as per below image, this action will rename the most recent file %Files[0]% in Downloads folder and add datetime using %CurrentDateTime% variable separate with underscore in custom format yyyy-MM-dd_hhmmsstt after the original file name, then store the new name in RenamedFiles variable.

Note: You can use other rename scheme e.g. set new name, add text, remove text, replace text, change extension, make sequential

Rename file(s)
Rename scheme “Add datetime” and how to set parameter

Display message

Use Display message action for check the Index 0 in RenamedFiles variable.

To retrieve a specific item in a list, use the following notation: %VariableName[ItemNumber]%

RenamedFiles variable data type is list of files, so we can use file properties for coding.

In this case, I want to display the name of renamed file so I set message to display as %RenamedFiles[0].Name%.

Display message
Set parameter as per this image for display file name of renamed file

Move file(s)

Use Move file(s) action for move the most recent file (the Index 0 in RenamedFiles variable) to destination folder.

  • File(s) to move: use file properties Fullname property from RenamedFiles variable %RenamedFiles[0].Fullname%.
  • Destination Folder: you can click folder icon and select your folder path such as “C:\Users\User\Desktop
Move file(s)

Set parameter as per this image for move file

Completed Flow

Completed flow
Completed Flow

Test and Check Result

Go to Dowloads folder, create new text file name as “TestRename.txt”

Downloads folder
The most recent file in Downloads Folder

Go to Power Automate Desktop, Press Save and Run.

At the 2nd line action, Display message, the message box will show C:\Users\User\Downloads\TestRename.txt

Display message result
Result from “Get files in folder” action (Sort Descending)

At 6th line action, Display message, the message box will show the Name property of renamed file as TestRename_2024-03-23-105851AM.txt

Display message result
Result from “Rename file” action (Name property)

Go to Destination folder, in this case is Desktop folder, we will found the Renamed file was moved to the destination folder successfully.

The renamed file was moved to Desktop Folder

Edited Flow for Ready to Use

You can copy code from github to Power Automate Desktop and input your destination folder in 5th line action, Set variable, then save and run

Edited Flow

Did You Enjoy this Article?

Subscription to get new articles sent to your inbox each week for FREE

Question?

If you have any questions or feedback about this article please leave a message in the comments section below.

Subscribe to get new articles sent to your inbox each week for FREE