Forum Discussion
pexperzen
Jul 25, 2022Copper Contributor
How to split name of the file to store in another field in Document Library?
Hi,
I have many file in Document Library and have a template of the name like picture below
and I would like to split '2501686' store in another field (ex. id_number) in the same Document Library.
Do you guy have any solution to suggest me?
pexperzen If you are using SharePoint online, you can use Power automate flow to update the column in library based on file name.
You can configure your flow something like this:
ID and Name in second action are dynamic data from first trigger in flow.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
It's difficult to answer without more context, so I'll make some assumptions.
1. You are looking for a SharePoint direct solution, not as part of PowerApps or Power Automate, or custom JavaScript.2. The format of your filename is always the same. i.e., a 7 digit number, then a space, then text.
Using the assumptions above, you can use a calculated column with the following formula:
=LEFT([Name],7)
If the number of digits varies, but is always followed by a space, you can use
=LEFT([Name],FIND([NAME," ")-1)
Calculated columns are great, but can be limiting. If you need a more robust solution, Power Automate has lots of options that Calculated Columns do not.
Here are a couple of links to help you with Calculated Columns.
https://sharepoint-tools.github.io/formulas.html
Good luck,
Don Kirkham
Please click Mark as Best Response & Like if my post helped you to answer or resolve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- pexperzenCopper Contributor
Don Kirkham Thank you for your suggestion. I applied your answer with ganeshsanap suggestion. 1. Create new columns filename_ma type Single line of Text and personal_no type Calculate Column and formula is =LEFT([filename_ma],7)
2. Create Power Automate Flow follow ganeshsanap suggestion and this is a result.
Thank you you guys so much!!
- pexperzenCopper Contributor
Thank you Don Kirkham for your kindly.
I do follow your suggestion but the output is 0. ( in filename_ma)
I have no idea what's my mistake. T^T
- I apologize. Further research reveals that the Name field is not available to use in a calculated column. Your only option is to use Power Automate. You have 2 options here:
1. Use Power Automate to populate the filename_ma column when a new document is added.
2. Use Power Automate to copy the filename into the Title column, then have filename_ma be a calculated column using Title (instead of Name)
Good luck!
pexperzen Do you have this fixed file format? number_text OR number<space>text?
If yes, you can create a power automate flow (on file creation/update OR scheduled flow). In flow, split the file name based on _ or <space>, then update the another column using "Update file properties" action with the value you get from split operation.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.