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 / Prepend existing file ...
Power Automate
Answered

Prepend existing file name with Last Modified date/time stamp

(0) ShareShare
ReportReport
Posted on by
Hello. I'm a rookie user. My goal is to prepend existing files with the last modified date/time stamp. I've succeeded with the current date/time, but keep failing with last modified. I've tried so many different flows, I'm not sure which one is best to post here.
 
The process is as follows:
Get files (properties only) (find all files created in the past 24 hours)
  • Filter Query: Modified gt '@{formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd')}'
 
Then, under a For Each:
Get file metadata (based on Identifier)
Get last modified time/date stamp in string format (I've tried several methods, none of which have worked)
Get file content (based on Identifier)
Create file
  • File Name: (concat LastModified + existing file name and extension)
  • File Content: body('Get_file_content')
Delete file (based on Identifier)
 
Again, I'm a rookie, so I apologize if this needs to be presented differently. Any help is appreciated.
Categories:
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    14,618 Super User 2026 Season 1 on at
    Where are these files stored? If they are stored in SharePoint, I would not bother. The modified column contains this data. If not implemented correctly, the modified date in the filename could not match the modified date field and cause confusion to users.
     
    If your files are in SharePoint, use the modified date value in your expression instead of trying to manipulate the utcNow() value.
  • Suggested answer
    Mark Nanneman Profile Picture
    993 Moderator on at
    Your "Get Files (properties only)" will include the date modified for each file.  But you'll want to convert it to a different file name friendly format.



    I'd recommend an expression like this:
    formatDateTime(item()?['Modified'],'yyyy-MM-dd_hhmmss')

    But you can format it however you like.  MM is month, mm is minutes.


     
  • Verified answer
    SynchroSting Profile Picture
    on at
    Thank you for your responses, @Mark Nanneman and @David_MA. Believe it or not, I got it working, and managed to keep it as simplistic as possible.
     
    Get files (properties only)
    • Filter Query: Modified gt '@{formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd')}'
    Find all files created or modified in the past 24 hours. I used modified only because If a file is only saved once, it's creation and modified dates should be the same.
     
    For Each:
    Get file metadata (based on Identifier)
    Get file content (based on Identifier)
    Create file
    • File Name: concat(formatDateTime(addToTime(body('Get_file_metadata')?['LastModified'], -8, 'Hour'), 'yyyy-MM-dd HH_mm_ss'), ' ', body('Get_file_metadata')?['Name'])
    • File Content: body('Get_file_content')
    File Name also converts UTC to CST.

    Delete file (based on Identifier)
     
    Original: Test file.docx (last modified 1/9 at 2:47 PM)
    Modified: 2025-01-09 14_47_22 Test file.docx
     
    I still need to confirm that the script will only affect files less 24 hours old, but the prepend is working great! Thanks again!

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 791

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 535

Last 30 days Overall leaderboard