Parse out specific number in filepath

brothaprice

New Member
Joined
Dec 12, 2020
Messages
13
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Web
Hello:

I pasted several filepaths from a folder into one column in Excel. I want to parse out a varying eleven-digit number found in every filepath. What is the easiest way to do this?

Here are some sample paths:

P:\mppub\Street Name and House Numbering\ADDRESSING_PDF_ARCHIVE\150th_St_E_47083_3314010044_201209.pdf

P:\mppub\Street Name and House Numbering\ADDRESSING_PDF_ARCHIVE\E_Ave_R-4_38320_3362012054_201212.pdf

The eleven-digit number would be 3314010044 in the first sample and 3362012054 in the second.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Is the number you want always followed by an underline character, 6 digits, a dot and a 3 character file extension?

Also, you say you want an eleven digit number, but your example is only 10 digits long. Do you really want a ten digit number or is your example flawed and you do, in fact, want an eleven digit number.
 
Upvote 0
with your examples
NameTBD
150th_St_E_47083_3314010044_201209.pdf3314010044
E_Ave_R-4_38320_3362012054_201212.pdf3362012054

Power Query:
let
    Source = Folder.Files("D:\test\pathpdf"),
    TSC = Table.SelectColumns(Source,{"Name"}),
    TBD = Table.AddColumn(TSC, "TBD", each Text.BetweenDelimiters([Name], "_", "_", {1, RelativePosition.FromEnd}, 0), type text)
in
    TBD
change path to the folder suitably
 
Upvote 0
Is the number you want always followed by an underline character, 6 digits, a dot and a 3 character file extension?

Also, you say you want an eleven digit number, but your example is only 10 digits long. Do you really want a ten digit number or is your example flawed and you do, in fact, want an eleven digit number.
Hello Rick. Thank you. You are right. It is 10 numbers. It is not always followed by 6 digits. Some files have 8 digits at the end instead of 6. YYYYMMDD instead of YYMMDD.
 
Upvote 0
Hello Rick. Thank you. You are right. It is 10 numbers. It is not always followed by 6 digits. Some files have 8 digits at the end instead of 6. YYYYMMDD instead of YYMMDD.
The 10-digit number should always follow by the second to last underscore
 
Upvote 0
This formula will return the number (as text just in case there are ever leading zeros)...
Excel Formula:
=TRIM(LEFT(RIGHT(SUBSTITUTE(A1,"_",REPT(" ",400)),800),400))
 
Upvote 0
Solution
with your examples
NameTBD
150th_St_E_47083_3314010044_201209.pdf3314010044
E_Ave_R-4_38320_3362012054_201212.pdf3362012054

Power Query:
let
    Source = Folder.Files("D:\test\pathpdf"),
    TSC = Table.SelectColumns(Source,{"Name"}),
    TBD = Table.AddColumn(TSC, "TBD", each Text.BetweenDelimiters([Name], "_", "_", {1, RelativePosition.FromEnd}, 0), type text)
in
    TBD
change path to the folder suitably
Thank you Sandy. I plan to try this in the future.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top