Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get filenames only from full path

Tags:

ant

I am using an Ant script to get the contents of a directory by means of the following:

<ac:foreach target="process-test" param="the_file" delimiter=",">
    <path>
        <fileset dir="${test.suite.url}">
            <include name="**/*.html"/>
            <exclude name="**/cases/"/>
        </fileset>
    </path>
</ac:foreach>

This is returning the full path to the file (which is something I also need) but, is it possible to strip away the path and give me just the filename?

like image 963
user228178 Avatar asked Jan 28 '10 17:01

user228178


People also ask

How do I get the filename from the file path?

To extract filename from the file, we use “GetFileName()” method of “Path” class. This method is used to get the file name and extension of the specified path string. The returned value is null if the file path is null.

How do I separate the filename and path in Python?

path. split() method in Python is used to Split the path name into a pair head and tail.

How do I get the filename in Excel from the path?

In Excel, there is no direct function to get the name of the file, but you can use the CELL function to get the path of the file, and then we can use the MID function to extract the file name from it.


1 Answers

Isn't the Ant <basename> task the thing you are looking for?

like image 196
Grzegorz Oledzki Avatar answered Oct 10 '22 14:10

Grzegorz Oledzki