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 / Add date (yyyymmdd) to...
Power Automate
Answered

Add date (yyyymmdd) to the beginning of selected file

(0) ShareShare
ReportReport
Posted on by 8

I'm new to Power Automate and have done some searching but not able to find the solution, hence the question in this forum. 

 

I want to automate the following: 

 

- File selected in File Explorer

- Hit Shortcut key

- File name is renamed and the current date yyyymmdd is added to the beginning of the file name. 

 

Renaming a file is something I found in the help and example files. But I was not able to find info about starting the workflow on a keyboard short cut as well as how to determine which file is selected in the File Explorer. 

 

Anybody can help? Or maybe has such an example script/workflow for me? Thanks. 

I have the same question (0)
  • Riyaz_riz11 Profile Picture
    4,204 Super User 2026 Season 1 on at

    Hi @rgroothuis 

    can you brief on this what it is required.

  • rgroothuis Profile Picture
    8 on at

    @Ahammad_Riyaz When in the File Explorer I've a file selected. With a keyboard shortcut I want to start a script that adds the date to the beginning of the selected file name.

     

  • Riyaz_riz11 Profile Picture
    4,204 Super User 2026 Season 1 on at

    Try this

     

    IMG_3624.png
  • rgroothuis Profile Picture
    8 on at

    Thanks @Ahammad_Riyaz for your quick suggestion. The Select File Dialog opens een window to select the file. In my case it is an extra manual action which takes time. I already have the file selected in the File Explorer. I only want to press a key combination which will trigger the workflow to update the "selected" file name by adding the date to the beginning. That is what I'm trying to achieve. 

     

    In the documentation I cannot find if it is possible to retrieve the selected file in explorer! And also I don't know how to kick off a workflow by using a keyboard shortcut. 

  • Gidi Profile Picture
    601 on at

    Hi rgroothuis,

    I think a solution with Power Automate will not make you lucky in this case, because starting a flow takes long time and you need it running all the time you want to use your shortcut. 

    Maybe a solution with using a batch file, with passing the files as arguments, that will be started via ‚send to‘ context menu in the file explorer is a more fitting solution for you. 

  • Verified answer
    MichaelAnnis Profile Picture
    5,727 Moderator on at

    Here you go.  It has to be continuously running in the background while you want to change files.  It loops continuously and waits for a shortcut key, and will use keyboard commands to rename the file (which you should have already selected).  The picture is just so you can see the visual, but you can literally copy and paste the code below to get you a good starting point and all you have to do is change the date format to whatever you want.  This code adds "_MMddyyyy" format on the end of the selected file name.  Good luck.

    MichaelAnnis_0-1683655635696.png

    LOOP WHILE (1) = (1)
    MouseAndKeyboard.WaitForShortcutKey.WaitForShortcutKey InputKeys: ['Ctrl+H'] IndexOfShortcutKeyPressed=> Key
    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> CurrentDateTime
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''MMddyyyy''' Result=> Datemmddyyyy
    MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''{Apps}m{Control}({Right})_%Datemmddyyyy%{Enter}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    END

  • rgroothuis Profile Picture
    8 on at

    Thanks for the feedback and suggestion. As @Gidi mentioned, maybe this is not the right tool to do this. I will continue searching. 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 463

#1
Valantis Profile Picture

Valantis 463

#3
11manish Profile Picture

11manish 264

Last 30 days Overall leaderboard