Skip to main content
Question

Automatically Name a Record Using Only Part of a Filename


Forum|alt.badge.img+1

I am hoping someone can help me with this! I have tried and tried to find a solution, but I’m having trouble. Currently, records are named using a PDF filename that is synced from a Google Drive folder. (ie -- 123456789.pdf) The number of digits before in the PDF range from 4 to 9 digits. Currently, the record name becomes G-123456789 in our table.

However, we have a new naming convention for our documents. So, I need to pull only PART of the filename to name the record. The new naming convention looks like this:

123456789 North Smith 04-03-2025.pdf

I need it to pull just the first number (123456789) to use to name the record in Airtable. I hope that makes sense, and I hope someone can help!

 

Thank you!

4 replies

Forum|alt.badge.img+3

Extract (for reference, can all be done in the Merge formula)

REGEX_EXTRACT({File Name}, "-(\\d+)")

 

Merge

REGEX_EXTRACT({File Name}, "-(\\d+)")&' '&Name&' '&DATETIME_FORMAT(Date, 'L')

 

 


DisraeliGears01
Forum|alt.badge.img+17

As it seems pretty standard this is easy to solve, as you can use a formula field to extract only the string that you need with the MID() function. 

For your example it would be something like MID({Filenamefield}, 2, 9), which would output only 123456789. Then you could combine that using Concatenate with your date and location fields to create an autotitle.


Forum|alt.badge.img+1
  • Author
  • New Participant
  • 1 reply
  • April 3, 2025
DisraeliGears01 wrote:

As it seems pretty standard this is easy to solve, as you can use a formula field to extract only the string that you need with the MID() function. 

For your example it would be something like MID({Filenamefield}, 2, 9), which would output only 123456789. Then you could combine that using Concatenate with your date and location fields to create an autotitle.

I used this and created a new column. However, I have a few issues. First, the number can be anywhere from 4-9 digits. With the MID function you gave me, it is including additional characters in my filename. (ie -- when the filename is 98765.pdf, it is assigning the name “98765.pdf “ since that would be 9 characters.) Basically, no matter the filename, I need it to just pull the first number.

So, if the filename is “123456789.pdf”, I need it to name it “123456789”. 

If it’s “123456789 North Smith 04-03-2025.pdf”, I need it to name it “123456789”.

If it’s “123456.pdf”, I need it to name it “123456”. 

And, if it’s “123.pdf”, I need it to name it “000123”.

The name needs to be a minimum of 6 characters with preceding zeroes if necessary and a maximum of 9 characters. But, I need it to drop anything after the first number. Is this even possible???


DisraeliGears01
Forum|alt.badge.img+17

Okay, I thought it was more structured than it was…

I think I’ve got a solution, try the below, subbing your field name for {Label}

CONCATENATE(REPT("0", 9-LEN(REGEX_EXTRACT({Label}, "(\\d+)"))), REGEX_EXTRACT({Label}, "(\\d+)"))

That should extricate the first string of digits and add 0 to the front to make every string 9 digits long. 


Reply