[Question] Hamilton Extracting the file name from a Path

I’m currently working on a method that queries a .CSV file that holds a multitude of different plate information. I wanted to use SQL commands to filter through this information to extract certain plates. However, for .CSV file SQL commands you need the file name. While many other examples do this they explicitly type out the name of the file.

For this use case the file path and name of the file need to be dynamic not explicit. TO that end I was wondering if there was a nice way of extracting the file name from the path. While I have seen the fillLib can find the Path given a directory and file name I was wondering if there is a similar library that can return the filename given a path.

Hi @Gellator,

Your best option for this is our HSLExtensions library, for which the installer can be downloaded at this link. This actually installs several libraries to the “HAMILTON\Library\HSLExtensions” folder. The one of interest to you will be the ‘File’ library, which has the following commands:

image

I suggest looking through some of the other libraries that are installed as well, since they contain many useful commands. I regularly use the String, File, Directory, Array, and Sequence libraries.

Let me know if you have any questions.

Thank you,
Dan

3 Likes

The File Extensions Library is going be the quickest, but i’ve also used the String library if you need to do this without any additional libraries:

1 Like