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 / folder from folder list
Power Automate
Answered

folder from folder list

(0) ShareShare
ReportReport
Posted on by 11

Hi,

 

I am looking to get folder from list of folder.

the list of folder is generated from 'get subfolder' from folder

 

I want to rename the 1st folder in the list. the list os ok with alist of folders.

I set the receivng target to value = %folder[0]%, %folder [0]%, folder [0]. no success. 

I am probably wrongwith sthing. any idea ?

chauffch_0-1712077106625.png

result is 

chauffch_1-1712077149157.png

 

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

    @chauffch 

    Please follow the below suggested approach to rename your folder:

    1. Get Subfolders: Start by getting a list of subfolders inside the folder located at your drive(Example: "C:\Deenu") and we will get all folder details in list.

    2. Rename Folder: In case if you want to rename only the first folder which comes in the above list then directly you can apply like below

    Deenuji_1-1712111400463.png

    Code:

    Folder.GetSubfolders Folder: $'''C:\\Deenu''' FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
    Folder.Rename Folder: Folders[0] NewName: $'''%Folders[0].Parent%\\NewFolderName''' RenamedFolder=> RenamedFolder

     

    Rename all folders:

    In case if you want to rename all the folder name in iteration you can use the below approach:

     

    Deenuji_0-1712079449609.png

     

     

    Code:

     

     

    Folder.GetSubfolders Folder: $'''C:\\Deenu''' FolderFilter: $'''*''' IncludeSubfolders: False 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
     Folder.Rename Folder: CurrentItem NewName: $'''%CurrentItem%_NewFolder''' RenamedFolder=> RenamedFolder
    END

     

     

    How to copy/paste the above suggested code into you Power automate desktop flow?

    Deenuji_1-1712079521499.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 🚀

     

  • sergiopereira83 Profile Picture
    25 on at

    If you want to always rename the first folder in the list, you can use the list folder variable, for example %Folders[0]% or %VAR_DEVIS_FOLDER[0]%, as input of rename action.

     

     

  • VishnuReddy1997 Profile Picture
    2,666 Super User 2026 Season 1 on at

    Hi @chauffch ,

     

    If you want only first folder to rename use the first solution.

     

    First Solution:

     

    VishnuReddy1997_0-1712105019376.png

     

    Code:

    Please Copy the Below code to your flow.

     

    Folder.GetSubfolders Folder: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice''' FolderFilter: $'''*''' IncludeSubfolders: False FailOnAccessDenied: True SortBy1: Folder.SortBy.NoSort SortDescending1: False SortBy2: Folder.SortBy.NoSort SortDescending2: False SortBy3: Folder.SortBy.NoSort SortDescending3: False Subfolders=> Folders
    Folder.Rename Folder: Folders[0].FullName NewName: $'''Contoso Invoicing Application''' RenamedFolder=> RenamedFolder

     

    If you want all folders to be Renamed in the list ,use the second solution.

     

    Second Solution:

     

    VishnuReddy1997_1-1712105361942.png

     

    Code:

    Please Copy the Below code to your flow.

     

     

    Folder.GetSubfolders Folder: $'''C:\\Users\\OneDrive\\Desktop\\Power Automate Desktop\\Practice''' FolderFilter: $'''*''' IncludeSubfolders: False 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
    Folder.Rename Folder: CurrentItem.FullName NewName: $'''%CurrentItem%_Copy''' RenamedFolder=> RenamedFolder
    END

     


    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Vishnu Reddy

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

    You seem to have Power Fx enabled in your flow. When you do that, the syntax is different and percentage symbols are no longer used for variable notation.

     

    Since Power Fx in desktop flows is still in preview and is not documented properly yet, I would recommend switching back, unless you absolutely need to use it. The only way to turn it off, however, is to create a new flow and keep this toggle disabled when you do that:

    Agnius_0-1712117692408.png

     

    Then re-create your actions in the new flow.

     

    For the record, if you have a list of folders in %Folders%, getting the first one as %Folders[0]% is correct, if you do not have Power Fx enabled. If you do, however, then you should get it as =Index(Folders,1) or =First(Folders).

  • Verified answer
    chauffch Profile Picture
    11 on at

    it works without Power FX. you're right. I will keep the working version (non Power FX).

    Thank you 

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

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 273 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 235

#3
David_MA Profile Picture

David_MA 172 Super User 2026 Season 2

Last 30 days Overall leaderboard