# Extract substring from filename

**URL:** <https://discuss.elastic.co/t/extract-substring-from-filename/230322>\
**Category:** Logstash\
**Created:** [April 29, 2020, 7:18am UTC](https://discuss.elastic.co/t/extract-substring-from-filename/230322 "2020-04-29T07:18:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammad\_hasan\_dabba](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohammad_hasan_dabba/32/61538_2.png) [@mohammad\_hasan\_dabba](https://discuss.elastic.co/u/mohammad_hasan_dabba)\
**Post date:** [April 29, 2020, 7:18am UTC](https://discuss.elastic.co/t/extract-substring-from-filename/230322/1 "2020-04-29T07:18:22Z")

</div>

hello, I have a typical issue but couldn't find the answer  
I want to extract file name and date-time from a file path  
this is how my file path looks like: /home/p188-mobiletradingpro-stresstest/stresstest/logs/999-241-jmeter-realtimePortfolio-services-POST-Gateway.org.jmx-run.jmx-2020-04-28--1636-IRDT.log

I want to have these two field:  
label: real-time portfolio or realtimePortfolio  
runAt: 2020-04-28--1636

file names are dynamic and their names are not the same  
can anyone help me pls?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 27, 2020, 7:18am UTC](https://discuss.elastic.co/t/extract-substring-from-filename/230322/2 "2020-05-27T07:18:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
