cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Wildtypitch
Helper I
Helper I

Populate Library metadata with filename elements

I'm sure this has been done many many times before and fairly simple but i need a bit of a hand to finish this. I'm very Noob to power automate but now want to do everything with it! SO much time saving potential on small things like this...

 

I've a filename ex. 0056-KAS-V1-01-A-DR-0111-GA Plan.pdf

 

This is a standard format and is always the same structure.

 

I want to split the name by '-' delimiter and put those values into different columns of the file metadata

So start with a "when file is created or modifies (properties only)" trigger

1.jpg

Then use Split(string(triggerBody()?['file']?['name']),'-')

 

To give me an array of the '-' separated string

 

2.jpg

Then a series of variables to identify those array strings 

 

How do I get the elements of the array, via index I presume? outputs[0], outputs[1] etc...? Basic I know...

I tried outputs('Compose')[1]

but computer says no!

 

Then I Feed these variable into the update file properties action right?

3.jpg

And that should be it right.

 

Will there be an infinite loop as the trigger looks for metadata changes and the result is a metadata change?

 

Ultimately some of these variables will be Store terms but that's another disco.

 

3 REPLIES 3
tom_riha
Super User
Super User

Hello @Wildtypitch ,

you don't need special variable for each part of the file name, you can repeat the split(...) expression for each of the metadata and just add the index at the end.

Split(string(triggerBody()?['file']?['name']),'-')[0]
Split(string(triggerBody()?['file']?['name']),'-')[1]
Split(string(triggerBody()?['file']?['name']),'-')[2]

And yes, if your flow is triggered on file update then updating the file will trigger the flow again = infinite loop risk. The metadata update from file name seems to me like a one-time action, maybe you could use the trigger 'When a file is created' instead of handling the infinite trigger loop.

 



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]
Wildtypitch
Helper I
Helper I

Hi I went with 

I created a variable BIMCode
split(triggerBody()['{name}'],'-')
not sure why I had string in there. Then 
 
variables('BIMCode')[0]
 
I kept them separate just for visual clarity.
 
I've gone with your on creation only suggestion. We've no need to apply after changes yet. But if we have to change the filename because one of the metadata fields changes over time we may have to do it manually. Wondering if there is a way to stop looping otherwise? 

Hello @Wildtypitch ,

there're some ways to avoid the looping based on the metadata:

  • if you have a special account used only in flows, you can check if the 'Modified' column is the service account (updated by flow, don't update again) or by some user (update)
  • or you can check the metadata value, you could have a huge condition that would check if all the columns already have the value they should have, if not = update, if yes = do nothing

It would be the updating flow + 1 extra flow triggered by the update, but the extra flow would not update anything = no loop.



[ If I have answered your question, please Accept the post as a solution. ]
[ If you like my response, please give it a Thumbs Up. ]

[ I also blog about Power Automate solutions even for non-IT people. ]

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,269)