cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Yin2021
Frequent Visitor

rename sharepoint file

 

I am trying to create a Flow that will automatically rename a file when it is uploaded to my SharePoint with the folder name: running number + File name

I can't seem to find a thread that is doing this, any advice would help.

 

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User II
Super User II

Hi @Yin2021,

 

In my flow I have added an additional action called Initialize variable. That variable is of type string and called LibraryName. I using the name of the library as a value, in my example SourceLibraryName. You can replace that by your library name.

 

libraryname.png

View solution in original post

3 REPLIES 3
Expiscornovus
Super User II
Super User II

Hi @Yin2021,

 

You could use a Send an HTTP request to SharePoint action an use the FileLeafRef field.

 

1. Add a When a file is created (properties only) action.

2. Add a Send an HTTP request to SharePoint action. Use the following configuration. Use the ID of the when a file is created action

 

URI

 

_api/web/lists/getByTitle('@{variables('LibraryName')}')/items(@{triggerOutputs()?['body/ID']})

 

 

Headers

 

{
  "Content-Type": "application/json;odata=nometadata",
  "X-HTTP-Method": "MERGE",
  "If-Match": "*"
}

 

 

Body

 

{ 'FileLeafRef': '01234-@{triggerOutputs()?['body/{Name}']}'}

 

 

renamefile_sendahttp.png 

Hi @Expiscornovus,

Thanks for your quick reply. but i am still new to Power automate. I try your flow but it pops out the error message. Do you mean i need to set the variable for my file name? 

Thanks. 

 

Yin2021_0-1614658337463.png

 

Expiscornovus
Super User II
Super User II

Hi @Yin2021,

 

In my flow I have added an additional action called Initialize variable. That variable is of type string and called LibraryName. I using the name of the library as a value, in my example SourceLibraryName. You can replace that by your library name.

 

libraryname.png

View solution in original post

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (26,813)