Here it is easier to do a Get file metadata and a Get file properties, and you'll get all the information that you need on the file. Picking a split from potentially deeper folders is a messy affair, ppleos, because SharePoint libraries move a lot of things around in terms of name.
I'll edit with examples shortly, but that will get more accurate data here.
In terms of getting the parent folder, I'm not sure if that is in either of those actions, but I know that it is in an Send an HTTPS call to SharePoint for a file's details.
If you want some data straight away look in the headers:
| File Name: |
triggerOutputs()?['headers/x-ms-file-name']
|
| File Path (including File Name): |
triggerOutputs()?['headers/x-ms-file-path']
|
However I far advise just running both (or either) of the two file information actions, @ppleos_.
If you wish to get more indirect information from that using expressions, then I've listed the the path, the path no last slash, and parent folder in the spoiler below:
Spoiler (Highlight to read)
Those expressions:
| Path no File Name: |
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
)
|
| Path no Name or final /: |
slice(
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
),
0,
-1
)
|
| Parent: |
if(
or(
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
null
),
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
''
),
empty(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1)
)
),
'/',
last(
split(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
'/'
)
)
)
|
As you may be able to tell, the second expression is used 4 times in the parent expression, to check against 3 types of emptiness, and to use if it isn't empty. This means that if the file is on the root of the checked library, it will show just a slash, and if it's anything else, the name of the parent folder only.
To get the parent name, it already doesn't have the file name or final slash, then you split it on slash '/', and take the last value. Boom.
If you don't care about that slash, then you can easily make it simpler.
If you only care about the parent name, then you're golden.
In the below spoler is some text that if you copy it all, and paste it directly into the input of a Compose action, then it should give you these expressions with very brief notations on the structure underneath them.
Spoiler (Highlight to read)
DIRECT
1 - Name
@{triggerOutputs()?['headers/x-ms-file-name']}
2 - Path
@{triggerOutputs()?['headers/x-ms-file-path']}
EXPRESSIONS
1 - Path no name:
@{replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
)}
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
)
2 - Path no name no last slash:
@{slice(
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
),
0,
-1
)}
slice(EXPRESSION_1, 0, -1)
3 - Parent folder:
@{if(
or(
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
null
),
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
''
),
empty(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1)
)
),
'/',
last(
split(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
'/'
)
)
)}
if(
or(
equals(
EXPRESSION_2,
null
),
equals(
EXPRESSION_2,
''
),
empty(
EXPRESSION_2
)
),
'/',
last(
split(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
'/'
)
)
)
|
That's all she wrote!
Here it is easier to do a Get file metadata and a Get file properties, and you'll get all the information that you need on the file. Picking a split from potentially deeper folders is a messy affair, ppleos, because SharePoint libraries move a lot of things around in terms of name.
I'll edit with examples shortly, but that will get more accurate data here.
In terms of getting the parent folder, I'm not sure if that is in either of those actions, but I know that it is in an Send an HTTPS call to SharePoint for a file's details.
If you want some data straight away look in the headers:
File Name:
triggerOutputs()?['headers/x-ms-file-name']
File Path (including File Name):
triggerOutputs()?['headers/x-ms-file-path']
However I far advise just running both (or either) of the two file information actions, .
If you wish to get more indirect information from that using expressions, then I've listed the the path, the path no last slash, and parent folder in the spoiler below:
Those expressions:
Path no File Name:
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
)
Path no Name or final /:
slice(
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
),
0,
-1
)
Parent:
if(
or(
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
null
),
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
''
),
empty(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1)
)
),
'/',
last(
split(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
'/'
)
)
)
As you may be able to tell, the second expression is used 4 times in the parent expression, to check against 3 types of emptiness, and to use if it isn't empty. This means that if the file is on the root of the checked library, it will show just a slash, and if it's anything else, the name of the parent folder only.
To get the parent name, it already doesn't have the file name or final slash, then you split it on slash '/', and take the last value. Boom.
If you don't care about that slash, then you can easily make it simpler.
If you only care about the parent name, then you're golden.
In the below spoler is some text that if you copy it all, and paste it directly into the input of a Compose action, then it should give you these expressions with very brief notations on the structure underneath them.
DIRECT
1 - Name
@{triggerOutputs()?['headers/x-ms-file-name']}
2 - Path
@{triggerOutputs()?['headers/x-ms-file-path']}
EXPRESSIONS
1 - Path no name:
@{replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
)}
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
)
2 - Path no name no last slash:
@{slice(
replace(
triggerOutputs()?['headers/x-ms-file-path'],
triggerOutputs()?['headers/x-ms-file-name'],
''
),
0,
-1
)}
slice(EXPRESSION_1, 0, -1)
3 - Parent folder:
@{if(
or(
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
null
),
equals(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
''
),
empty(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1)
)
),
'/',
last(
split(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
'/'
)
)
)}
if(
or(
equals(
EXPRESSION_2,
null
),
equals(
EXPRESSION_2,
''
),
empty(
EXPRESSION_2
)
),
'/',
last(
split(
slice(replace(triggerOutputs()?['headers/x-ms-file-path'], triggerOutputs()?['headers/x-ms-file-name'], ''), 0, -1),
'/'
)
)
)
That's all she wrote!