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 / Remove last 13 charact...
Power Automate
Answered

Remove last 13 characters from file name

(0) ShareShare
ReportReport
Posted on by 15

Hi Everyone,

 

I am very new to Power automate and I am trying to build a flow to get files in a folder and rename them as they all have 13 characters at the end that I need to get rid of

 

KAM_0-1717330485650.png

I just need them to say Daily_Sales_-_Bath_2024-05-29 and Daily_Sales_-_Bath_2024-05-30

 

I need to get rid of the_06_00_00_065 bit and _06-00-00-049 bit in this instance but I have another 27 of them every day with different numbers at the end. A detailed flow would be much appreciated as I am still learning.

 

Thank you.

I have the same question (0)
  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KAM 

     

    You have the option to utilize the "Get Subtext" action, specifying the desired number of characters you wish to keep. This action will remove any excess characters beyond that specified length.

     

    Deenuji_0-1717334930879.png

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • KAM Profile Picture
    15 on at

    Hi Deenuji, thank you for your swift reply, the only thing is that the file name varies i.e. instead of Bath within the name it could say Australia therefore the number of characters at the beginning is not always going to be the same?

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KAM 

     

    So you are saying instead of "Bath" each file name contains any country names or only Australia?

     

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KAM 

     

    Let's go with regex for your use case:

    Deenuji_0-1717336910993.png

     

    Regex used: ^(.*?)_\d{4}-\d{2}-\d{2}

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • KAM Profile Picture
    15 on at

    Hi Deenuji. sorry if i did not explain it correctly these are are couple of the other files in the same folder

     

    KAM_0-1717337197783.png

    Would that work on what your last reply was? Once again thanks for helping out.

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KAM 

     

    It should work please check and let me know in case of any issues

  • KAM Profile Picture
    15 on at

    Hi Deenuji

     

    Sorry this is all very new to me, is this correct or am I missing steps

     

    KAM_0-1717340482455.png

     

  • CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KAM 

     

    Please follow the below approach:

    Deenuji_0-1717341152871.png

     

     

    Code(follow the below gif how to copy/paste the below code into your power automate desktop):

    Folder.GetFiles Folder: $'''C:\\Deenu\\Json\\csv''' FileFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
    LOOP FOREACH CurrentItem IN Files
     Text.ParseText.RegexParseForFirstOccurrence Text: CurrentItem.Name TextToFind: $'''^(.*?)_\\d{4}-\\d{2}-\\d{2}''' StartingPosition: 0 IgnoreCase: True OccurrencePosition=> Position Match=> Match
     Display.ShowMessageDialog.ShowMessage Title: $'''Info''' Message: Match Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    END

     

    How to copy/paste the above code into your power automate desktop:

    Deenuji_1-1717341243180.gif

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

     

  • KAM Profile Picture
    15 on at

    Hi

    I followed the steps above and they all come up with the correct file name but when I go into the folder where they are stored the names have not changed, could you tell me what I need to do now.

  • Verified answer
    CU16071609-1 Profile Picture
    6,255 Moderator on at

    @KAM 

    You can add "rename file(s)" action next to parse text and configure like below:

    Deenuji_0-1717343436952.png

     

    Now full flow looks like this:

    Deenuji_1-1717343499702.png

     

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

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

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 272 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 147 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 146 Super User 2026 Season 2

Last 30 days Overall leaderboard