<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I extract a file name from a file path? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289618#M87620</link>
    <description>&lt;P&gt;This worked, thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 15 Aug 2017 17:37:21 GMT</pubDate>
    <dc:creator>JustRoot</dc:creator>
    <dc:date>2017-08-15T17:37:21Z</dc:date>
    <item>
      <title>How can I extract a file name from a file path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289614#M87616</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;So currently, one of my indices logs has the file path which contains the file name but doesn't have a separate file name field. Is there any way to extract the filename? For example, if c:\users\user1\desktop\file.exe is my file path, I want to see file.exe.&lt;/P&gt;

&lt;P&gt;Have: &lt;BR /&gt;
c:\users\user1\desktop\file.exe&lt;/P&gt;

&lt;P&gt;Want:&lt;BR /&gt;
file.exe&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;PS - I know there are other posts on this, but the solutions offered on those didn't work for me.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 14:20:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289614#M87616</guid>
      <dc:creator>JustRoot</dc:creator>
      <dc:date>2017-08-15T14:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract a file name from a file path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289615#M87617</link>
      <description>&lt;P&gt;I'm going to assume that you have the full path in a field and that you are doing a search time extraction with the &lt;CODE&gt;rex&lt;/CODE&gt; command. Do something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | rex field=path "(?P&amp;lt;file&amp;gt;[^\\\]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you are using the &lt;CODE&gt;source&lt;/CODE&gt; field, then just substitute &lt;CODE&gt;source&lt;/CODE&gt; for &lt;CODE&gt;path&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Edited. - needed an extra backslash in the &lt;CODE&gt;rex&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 15:58:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289615#M87617</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-15T15:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract a file name from a file path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289616#M87618</link>
      <description>&lt;P&gt;&lt;IMG src="https://i.imgur.com/3Mb8BJ0.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;This is the error I get using the exact solution you provided.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 17:00:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289616#M87618</guid>
      <dc:creator>JustRoot</dc:creator>
      <dc:date>2017-08-15T17:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract a file name from a file path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289617#M87619</link>
      <description>&lt;P&gt;Try adding another backslash, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;your search&amp;gt; | rex field=Process_Name "(?P&amp;lt;file&amp;gt;[^\\\]+)$"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Aug 2017 17:29:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289617#M87619</guid>
      <dc:creator>masonmorales</dc:creator>
      <dc:date>2017-08-15T17:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: How can I extract a file name from a file path?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289618#M87620</link>
      <description>&lt;P&gt;This worked, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2017 17:37:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-extract-a-file-name-from-a-file-path/m-p/289618#M87620</guid>
      <dc:creator>JustRoot</dc:creator>
      <dc:date>2017-08-15T17:37:21Z</dc:date>
    </item>
  </channel>
</rss>

