Search code examples
rr-faq

Get filename without extension in R


I have a file:

ABCD.csv 

The length before the .csv is not fixed and vary in any length.

How can I extract the portion before the .csv?


Solution

  • There's a built in file_path_sans_ext from the standard install tools package that grabs the file without the extension.

    tools::file_path_sans_ext("ABCD.csv")
    ## [1] "ABCD"