How to get a folder ID by name and rename it via API

Hi there,
I need some help:
a) I have a list of folders which I want to rename (full path)
b) I use the GetFiles API which doesn’t return the folder ID (doh!) but just the files contained within that folder
c) I want to rename those folders (keeping the same files inside) for example a/b/c to a/b/cc keeping the same files inside

What’s the best way to achieve this?

You can get the ID of the directory by using the Files: Get API with some appropriate filters. Using your example of a directory of /a/b/c, you’d make a request like …

GET https://api.losant.com/applications/{applicationId}/files?directory=/a/b/&filterField=name&filter=c&type=directory

With the directory ID in hand, you can then use the File: Move API endpoint. Moving to a directory of /a/b/cc would look like:

POST https://api.losant.com/applications/{applicationId}/files/{fileId}?parentDirectory=/a/b/&name=cc
1 Like

Hello thanks for the tip, it was a bit counter-intuitive to begin but I managed to fully automate it.
Cheers.