I almost have this working but I am stuck on getting the folder created.
I am keeping two ODFB (OneDrive for Business) location in sync. I have one Trigger and One Action in the Power Automate Flow.
1. (Trigger) When a file is Created in Source
2. (Action) Create a file in Destination
The action requires 3 properties to work (a) Folder Path (b) File name (c) File content. (b) and (c) I can get from the Trigger.
For (a) the Folder Path I need to create the folder path if it does not exist. This works if I supply a folder name that doesn't exist then it will create it. I am using an expression as follows to create the folder:
last(split(base64ToString(triggerOutputs()?['headers']['x-ms-file-path-encoded']),'root:/'))
This creates a folder but the folder it creates is the name of the file rather than just the folder path. For example, if the name of the file it is supposed to create is "somefile.txt" in "FolderX". Then it will create a folder as follows in the ROOT (/) -> /folder1/folder2/somefile.txt/somefile.txt
The file is created but it is created inside a folder.
How can I use my expression in the File path property to create /folder1/folder2/somefile.txt folder path instead?