Based on the separating character, file_ext determines the file extension and path_no_ext determines the file path without the extension.

file_ext(path, sep_char = ".")

path_no_ext(path, sep_char = ".")

Arguments

path

character value of the file path possibly with an extension.

sep_char

character value of the separator that delineates the extension from the file path. Generally, this will be ".", but for some API URLs, the extension is actually a query component, so the separator may sometimes need to be "=".

Value

character value of the extension (file_ext) or the path without the extension (path_no_ext.

Examples

 file_ext("home/folders.with.dots/stuff/ok.csv")
#> [1] "csv"
 path_no_ext("home/folders.with.dots/stuff/ok.csv")
#> [1] "home/folders.with.dots/stuff/ok"