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 / Bulk edit folder names
Power Automate
Answered

Bulk edit folder names

(0) ShareShare
ReportReport
Posted on by 7

Is there a way to bulk edit folder names?  I would like to remove spaces from the folder names.  I am able to use Desktop Flow to rename file names, but can't seem to do it with folders.

I have the same question (0)
  • UshaJyothiKasibhotla Profile Picture
    225 Moderator on at

    try this 

    Use get file in folder activity

    Loop through it by for each each 

    Take currentitem.path

    From this variable use remove text or replace text activities and remove spaces 

    Then use rename files by using rename file activity 

    Hope this helps 

    Usha

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    There's a Rename folder action that is available in PAD under the "Folder" actions group. It can only rename one folder at a time and you need to specify the folder name.

    So, if you want to simply remove whitespaces, a simple way to do it would be following this:

    Agnius_0-1699678863111.png

     

    What it does is as follows:

    1. Get subfolders in folder will get you the folders in some root directory. I've used a filter with * * which will return any folders that have whitespaces in their names.
    2. For each is a type of loop that iterates through a collection (in this case a list of folders returned by the previous action) and stores the current item into a variable %CurrentItem% for each iteration.
      1. Replace text with regular expressions to replace \s (which represents a whitespace in regular expressions language) with %""% (which represents an empty string in PAD). Replace whitespaces in %CurrentItem.Name% and store the output into a new variable, like %NewName%.
      2. Rename folder to change the name of %CurrentItem% to %NewName%
    3. End loop

     

    Here's a code snippet you can copy and paste directly into your PAD flow designer to have these actions created for you:

    Folder.GetSubfolders Folder: $'''C:\\RPA''' FolderFilter: $'''* *''' IncludeSubfolders: True FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
    LOOP FOREACH CurrentItem IN Folders
     Text.Replace Text: CurrentItem.Name TextToFind: $'''\\s''' IsRegEx: True IgnoreCase: False ReplaceWith: $'''%''%''' ActivateEscapeSequences: False Result=> NewName
     Folder.Rename Folder: CurrentItem NewName: NewName RenamedFolder=> RenamedFolder
    END
    

     

    Note: You will need to change the directory from which subfolders should be retrieved in Get subfolders in folder.

    -------------------------------------------------------------------------
    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.

  • Jess22 Profile Picture
    7 on at

    Can you tell me where to paste the code.  

  • Jess22 Profile Picture
    7 on at

    I was able to figure out how to paste the code separately for each action & got it to work!!!  Thank you for the code & explanation.  If you could still let me know how to paste the code for all actions that would be great.  Just wondering for future reference.  Also, Is there a way to rename file names at the same time?  I figured out how to do this separately, but just thought it would be nice to do them together.  Again, Thank you for this.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You could just copy and paste the entire thing directly into the designer window and it should create all actions. It could be, though, that if you use an older version of PAD than mine, some actions are incompatible and then you wouldn't be able to paste it, but it would then work when pasting each action separately. But in general, you should be able to do it for all of them at once.

     

    If you have a further question regarding file names, please provide more context as to what exactly you want. Maybe even create a separate topic, as it is not really related to this one.

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

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 262 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 167

#3
Haque Profile Picture

Haque 154

Last 30 days Overall leaderboard