up:: PowerAutomate
Solved: How to get the last 4 characters of a string? - Power Platform Community
How to split file name for further processing in Power Automate
If you need to extract number or text from the file name, you can use substring
method:
invoices_01.2023.xlsx
substring(outputs('Compose'),sub(length(outputs('Compose')),5),5)
substring(triggerOutputs()?['body/{Name}'],sub(length(triggerOutputs()?['body/{Name}']),7),7)
And if there is a date in the end, you can also use split
method:
split(substring(triggerOutputs()?['body/{Name}'],sub(length(triggerOutputs()?['body/{Name}']),7),7),'.')
In one Parse Json Action:
{
"file month": "@{split(substring(triggerOutputs()?['body/{Name}'],sub(length(triggerOutputs()?['body/{Name}']),7),7),'.')?[0]}",
"file year": "@{split(substring(triggerOutputs()?['body/{Name}'],sub(length(triggerOutputs()?['body/{Name}']),7),7),'.')?[1]}"
}
{
"type": "object",
"properties": {
"file month": {
"type": "string"
},
"file year": {
"type": "string"
}
}
}
Result: