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 Automate
Unanswered

rename files

(0) ShareShare
ReportReport
Posted on by 352 Moderator

I need a flow to change the folder names . I have a folder like

zbegumdost_0-1691397138505.png

I need to change this names xx-1 to xx-5 , xx-2 to xx-6 . How can I filter the folder names?

I have the same question (0)
  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    I don't really understand what you mean here. Do you need to rename folders or files? Can you provide an example of a pair of items with the existing name and the expected result?

     

  • arcado Profile Picture
    352 Moderator on at

    I meant files.

    Like 911362_2001-1.jpg should be 911362_2001-5.jpg and

     911362_2001-2.jpg should be 911362_2001-6.jpg

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You will need to use Get files in folder to get all your files sorted by name in descending order (so that you don't start renaming files to names that already exist), then loop through them, get the index out, increase it and then use Rename file(s) to rename each file separately.

     

    A sample flow could look like this:

    Agnius_0-1691408441788.png

     

    Here's a snippet you can copy and paste directly into PAD to have those actions created for you:

    SET Directory TO $'''C:\\RPA'''
    Folder.GetFiles Folder: Directory FileFilter: $'''*.jpg''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NameWithoutExtension SortDescending1: True SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Files=> Files
    LOOP FOREACH CurrentFile IN Files
     Text.ParseText.RegexParseForFirstOccurrence Text: CurrentFile.NameWithoutExtension TextToFind: $'''(?<=-)\\d+''' StartingPosition: 0 IgnoreCase: False OccurrencePosition=> Position Match=> Match
     Text.ToNumber Text: Match Number=> TextAsNumber
     SET NewNumber TO TextAsNumber + 4
     Text.FromNumber Number: NewNumber DecimalPlaces: 0 UseThousandsSeparator: False FormattedNumber=> FormattedNumber
     File.RenameFiles.RenameReplaceText Files: CurrentFile TextToReplace: $'''-%Match%''' ReplaceWith: $'''-%FormattedNumber%''' IfFileExists: File.IfExists.DoNothing RenamedFiles=> RenamedFiles
    END

     

    Please note you will need to provide the actual path to the folder for the %Directory% variable.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

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 253 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 172 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 134 Super User 2026 Season 2

Last 30 days Overall leaderboard