Skip to main content
Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
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 

  • Verified answer
    Wilson1981_ Profile Picture
    19 on at
    Re: Flow to rename files based on an excel spreadsheet


    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 

  • fchopo Profile Picture
    7,972 Super User 2025 Season 1 on at
    Re: Flow to rename files based on an excel spreadsheet

    Hi @Wilson1981_ 

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

    compose.png

     

    Hope it helps!

    Ferran

     

  • Wilson1981_ Profile Picture
    19 on at
    Re: Flow to rename files based on an excel spreadsheet

    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
    7,972 Super User 2025 Season 1 on at
    Re: Flow to rename files based on an excel spreadsheet

    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
    Re: Flow to rename files based on an excel spreadsheet

    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
    7,972 Super User 2025 Season 1 on at
    Re: Flow to rename files based on an excel spreadsheet

    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

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1