I want to be able to pull a URL for the "containing folder" of a file I access via SharePoint using Power Automate. For instance, if I create a folder named foo and I have a document in that folder foo/foo.doc, I want the URL of the folder foo. Ideally, I'd also be able to ensure this link is shared to my organization.
2 Answers
I tested with Matiur's formula and it does not work quite well. Here is a new formula working in my end. You can try both of them.
substring(outputs('Get_file_properties')?['body/{Link}'],0,lastIndexOf(outputs('Get_file_properties')?['body/{Link}'],'/'))
For knowing if it has been shared. I think is is not doable OOTB in power automate.
After getting the properties of the file by using [Get file properties] action, you use the following expression to get the link to the folder that the file is in.
Property {Link} contains the full url of the document and replacing {FilenameWithExtension} from {Link} with empty string('') by concatenating '/' at the beginning results in the full path to the folder.
replace(outputs('Get_file_properties')?['body/{Link}'], concat('/', outputs('Get_file_properties')?['body/{FilenameWithExtension}']), '')
