Get filename without extension in R

Matrix.cursor picture Matrix.cursor · Mar 18, 2015 · Viewed 59.7k times · Source

I have a file

ABCD.csv 

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

How can I extract the portion before the .csv.

Answer

Tyler Rinker picture Tyler Rinker · Mar 18, 2015

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"