SOLVED

How to split name of the file to store in another field in Document Library?

Copper Contributor

Hi,

 

I have many file in Document Library and have a template of the name like picture below

pexperzen_0-1658734826054.png

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?

 

 

6 Replies

@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.

@pexperzen 

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://support.microsoft.com/en-us/office/introduction-to-sharepoint-formulas-and-functions-94e1b4c...

 

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.

 

 

 

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

pexperzen_0-1658904493207.png

 

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!
best response confirmed by pexperzen (Copper Contributor)
Solution

@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:

ganeshsanap_0-1658991714676.png

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.

@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.

pexperzen_0-1659416632980.png

Thank you you guys so much!! :hearteyes:

1 best response

Accepted Solutions
best response confirmed by pexperzen (Copper Contributor)
Solution

@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:

ganeshsanap_0-1658991714676.png

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.

View solution in original post