# How to get a File name from a complete File path

**URL:** https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34
**Category:** How To
**Created:** [May 19, 2015, 7:41am UTC](https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34 "2015-05-19T07:41:55Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Dawie\_Botes](https://community.linx.software/community/user_avatar/community.linx.software/dawie_botes/32/288_2.png) [@Dawie\_Botes](https://community.linx.software/community/u/Dawie_Botes)
#### Post date: [May 19, 2015, 7:41am UTC](https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34/1 "2015-05-19T07:41:55Z")

</div>

When using a FileOpen or FileList control in Linx, and you receive a Full File Path, in some instances you’d like to extract the File name from the File path. Thus you can use an SQL query, with the input of the Full path:

```
DECLARE @full_path varchar(max)
Select @Full_Path = @{OpenGenerateFile.File.FilePath}

SELECT LEFT(@full_path, LEN(@full_path) - CHARINDEX('\', REVERSE(@full_path))) as NameOfFolder,
        RIGHT(@full_path, CHARINDEX('\', REVERSE(@full_path)) - 1) as NameOfFile

```

For example, if {OpenGenerateFile.File.FilePath} was “C:\Linx\BB\Export.csv” then the result will be:

> NameOfFolder: “C:\Linx\BB”  
> NameOfFile: “Export.csv”

---

<div class="post-metadata">

### Author: ![gawie](https://community.linx.software/community/user_avatar/community.linx.software/gawie/32/185_2.png) [@gawie](https://community.linx.software/community/u/gawie)
#### Post date: [May 19, 2015, 10:17am UTC](https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34/2 "2015-05-19T10:17:15Z")

</div>

You can also use the Linx RegularExpression function. To get the filename from the full path use something like (?\<=\)[^\]+$ . The filename is then available to all other Linx functions that are in scope.

We have a story in our backlog that adds functionality to the Linx Expression Editor to manipulate paths. The idea is to have something like =$.FilePath.GetFileName(FullPathHere) extract the path.

---

<div class="post-metadata">

### Author: ![Dawie\_Botes](https://community.linx.software/community/user_avatar/community.linx.software/dawie_botes/32/288_2.png) [@Dawie\_Botes](https://community.linx.software/community/u/Dawie_Botes)
#### Post date: [May 19, 2015, 12:44pm UTC](https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34/3 "2015-05-19T12:44:53Z")

</div>

Thank you Gawie, this works great. I’ve done a quick solution to use it:

The result:

>

---

<div class="post-metadata">

### Author: ![ronan](https://community.linx.software/community/user_avatar/community.linx.software/ronan/32/433_2.png) [@ronan](https://community.linx.software/community/u/ronan)
#### Post date: [May 31, 2021, 9:59am UTC](https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34/4 "2021-05-31T09:59:36Z")

</div>



---

<div class="post-metadata">

### Author: ![ronan](https://community.linx.software/community/user_avatar/community.linx.software/ronan/32/433_2.png) [@ronan](https://community.linx.software/community/u/ronan)
#### Post date: [May 31, 2021, 10:26am UTC](https://community.linx.software/community/t/how-to-get-a-file-name-from-a-complete-file-path/34/5 "2021-05-31T10:26:52Z")

</div>


