How can we extract the File name from File Path?

-File Path Sample=“C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf”
-I want to extract the file name [Test-1] from Whole File Path.

@annet_mdamugade

Use
strFileName = system.io.Path.GetFileNameWithoutExtension("C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf")

Thanks,
Ashok :slight_smile:

1 Like

@annet_mdamugade

Path.GetFileNameWithoutExtension("C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf")
1 Like

Hi @annet_mdamugade

FilePath = "C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf"

FileName = System.IO.Path.GetFileNameWithoutExtension(FilePath).ToString

Regards,

Hi @annet_mdamugade,

Good Morning, You can extract the file name and filename without extension as follows.

With Extension:-

Path.GetFileName(“C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf”) —> Test-1.pdf

Without Extension:-

Path.GetFileNameWithoutExtension(“C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf”) —> Test-1

Please mark it as a solution if it resolves your issue.

1 Like

Hi @annet_mdamugade

filePath = "C:\Users\11649\Documents\UiPath\Action Centre Invoice Validation Process\Data\Output\OutPut Zip Folder\Zip Folder\Test-1.pdf"

fileName = System.IO.Path.GetFileNameWithoutExtension(filePath)

Hope it helps!!

1 Like

Hie @annet_mdamugade you can try this method
First create string variable to hold the folder path - variable string
image
create a variable of array of string with hold the file location
image
use for each to iterate
image
output result
image

cheers Happy Automation

1 Like

and if you have only single file then use this
create a string variable pass the file path

1 Like

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