cancel
Showing results for 
Search instead for 
Did you mean: 

Rename a File in Sharepoint

Can you please add the feature "change the name of a file" in the connector as it is posible in oneDrive

Thanks.

Status: New
Comments
TheWookieEng
New Member

Please, add... this is needed.

JonasSav
Frequent Visitor

I'm crying out loud for it.

How can such a simple need can't we achieved in such a complex solution.

sean_cale
Regular Visitor

This is such a simple feature. How is there no way to rename a file? Very irritating.

kweighall
Frequent Visitor

Why is this still an issue??  This feature request was submitted THREE YEARS AGO.  Get it together Microsoft!

RobertMoriarty
New Member

This would be very helpful.  I found a workaround in copying the contents of a file to the next file, then removing the original.  This doesn't work as straight forward on onenote files, but the built in rename function manually on sharepoint works correctly to rename the onenote files.

MarcBoes
Frequent Visitor

Hi @RobertMoriarty , i'd suggest you use the send http request to SharePoint instead (see https://docs.microsoft.com/en-us/answers/questions/306837/renaming-sharepoint-file-using-rest-api-wi... for an example). That way your file history and created/modified details are preserved.

* edit * Credit where credit is due: @DawgPoundMBA1 submitted the same answer earlier in the thread. I understand the complaints of the other people in this thread regarding the obscure way to do this basic action, but it's doable and without a premium licence at least.

Additional tip: by including the editor property, you can preserve the latest 'modified by' of the item.

Best regards, Marc

tom_riha
Super User

I believe there's an easier HTTP request to rename a file.

image.png

MarcBoes
Frequent Visitor

@tom_riha, you're to modest 😉

And yeah, you're right. Your posts Update single SharePoint column in Power Automate with HTTP request and Update SharePoint column without new item version in Power Automate should help everyone needing this feature. Cheers!

eliotcole
Power Participant

This is all well and good. @tom_riha & @MarcBoes , but I can't for the life of me get that to work for items placed into the General folder which is a sub-folder of all Documents folder libraries. The IDs are different, and if I'm not mistaken it's dealt with as an entirely different list.

 

However even if I place the correct list ID for the General folder and use a GUID reference or getbyid, it still won't rename the file. 😞

 

Ignore me, I was sending the wrong type of HTTP request. This works, but I would guess that you do need to specify the ID (using GetById('INSERT_LIST_ID_HERE')) rather than the Title (using GetByTitle('General')), as it won't recognise 'General'.

 

Does it work with 'Documents\General' or 'Documents/General' if you do it by name?

 

OK, I was wrong ... the ID is for any files created in the Documents library ... the 'General' folder (something that will be used a lot if you use Teams) is just another item in the list, and any items in that folder are numbered sequentially with items in the main Documents library. So ... in short ... just use 'Documents'! 😅

MarcBoes
Frequent Visitor

@eliotcole , to update an item you don't need to specify the folder. The moment you know either the ListID or the title of the list/library, you can update all items based on the ID regardless of their (sub) folder.

If you need to find out which items/files are in a particular folder first to get to the ID's, then you can get those with 

_api/Web/GetFolderByServerRelativeUrl(<folder url>)?$expand=Files

For example I have a site /sites/dms-kb with a resources folder in the Documents library.

 

https://<mytenant-host-name>/sites/dms-kb/_api/Web/GetFolderByServerRelativeUrl('/sites/dms-kb/Shared%20Documents/Resources')?$expand=files

 

returns the files.

To get the ItemID of the file, you can call something like: 

Web/GetFileByServerRelativePath(decodedurl='/sites/dms-kb/Shared%20Documents/Resources/Cultural%20%20Dimensions.png')/ListItemAllFields/ID

Note that this method can also be used to find the ListID or title of a library in cases where you only have the URL, for example:

 

https://<my-tenant-host>.sharepoint.com/sites/dms-kb/_api/Web/GetFolderByServerRelativeUrl('/sites/dms-kb/Shared%20Documents')/name

 

Returns (XML output from the browser):

<d:Name ...">Shared Documents</d:Name>

If that is not what you meant, do let me know!

<edit: never mind, you updated your post while I was typing. This reply is here till I find a way to delete it.>

Cheers,

Marc