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 / Flow to rename files b...
Power Automate
Answered

Flow to rename files based on an excel spreadsheet

(0) ShareShare
ReportReport
Posted on by 19

Hi all I am looking for some help in creating this one. I have all my attachments saving to a onedrive directory. Once they are in the directory my AI model goes over them and extracts details :-

Order number 

customer number 

customer name 

purchase order 

These are copied into a spreadsheet.

 

I want to create a flow to rename the files based on the entries in the spreadsheet and then move to another directory based on the file name 

 

any ideas 

 

thanks in advance 

Categories:
  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @Wilson1981_ 

    On what depends the directory name where you want to move the file? Have a look at this example:

    aibuilder.png

     

     The steps are:

    1) List all files in OneDrive

    2) For each element, chech if it's a file

    3) If it's a file, pass its content to AI Builder

    4) Use the output of the previous step to define the file name (compose action).

    5) Move or rename the file to the desired location and with the specified file name.

     

    Hope it helps!

    Ferran

  • Wilson1981_ Profile Picture
    19 on at

    Hi Ferran

     

    Thanks for the help on this ,y flow looks like this 

     

    Wilson1981__0-1617835313899.png

     

    But when I run it it gives me this error 

     

    The destination '/drives/b!RD417gNtGEeorMEn_7p0mQq2AhOZRX5Cufy3Oz9blylreIEqkfGkSo9En9jNknuD/root:/Cosworth/Attachments/0009008849_866_SO_453347.pdf' cannot be a file.

     

    I thought it would just overwrite this or do i need to change it to the folder location 

     

    thanks in advance 

     

    Will 

     

  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @Wilson1981_ 

    You can get the path of the onedrive folder using the following expression:

    last(split(triggerOutputs()?['headers']['x-ms-file-path'],'root:/'))

    So you would have something like this (be careful with the "/"):

    onedrive.png

     

    Hope it helps! 

    Ferran

  • Wilson1981_ Profile Picture
    19 on at

    Hi Ferran 

     

    Thanks for the help so far, i tried what you suggested and got the below error

     

    The file id '/drives/b!RD417gNtGEeorMEn_7p0mQq2AhOZRX5Cufy3Oz9blylreIEqkfGkSo9En9jNknuD/root:/Cosworth/Attachments/0009008849_866_SO_4533471.pdf' is not valid.

     

    Here is the flow i have put together on this 

     

    Wilson1981__0-1617916237853.png

     

    Have i missed something obvious on this

     

    Thanks 

     

    Will

  • fchopo Profile Picture
    8,003 Moderator on at

    Hi @Wilson1981_ 

    You have to write the expression inside the expression field, not as a string:

    compose.png

     

    Hope it helps!

    Ferran

     

  • Verified answer
    Wilson1981_ Profile Picture
    19 on at


    Hi Ferran 

     

    I have managed to get it to work, I have removed the compose function.

     

    as you can see from the attached flow I was going about it slightly wrong 

     

    AD004D2E-5876-4329-901F-596183D3AF47.jpeg

    thank you for all your help on this 

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
11manish Profile Picture

11manish 231 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 217 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 170

Last 30 days Overall leaderboard