Skip to contents

Helper functions that make the paths to a file shorter.

Usage

drop_path(x, ...)

drop_extension(x, ...)

short_names(x, ...)

Arguments

x

An object of class fnames or a character vector.

...

Additional arguments.

Value

An object of the same class as x.

Functions

  • drop_path(): Extract the base name of a path, removing the paths leading to it.

  • drop_extension(): Remove extension from a filename.

  • short_names(): Remove both paths leading to a file and its extension.

Examples

cwd_fnames <- as_fnames(c("folder/file1.txt", "folder/file2.txt", "folder/file3.txt"))
drop_path(cwd_fnames)
#> Filename collection of length 3
#>    filename
#>   ---------
#> 1 file1.txt
#> 2 file2.txt
#> 3 file3.txt
drop_extension(cwd_fnames)
#> Filename collection of length 3
#>       filename
#>   ------------
#> 1 folder/file1
#> 2 folder/file2
#> 3 folder/file3
short_names(cwd_fnames) # same as drop_path(drop_extension(cwd_fnames))
#> Filename collection of length 3
#>   filename
#>   --------
#> 1    file1
#> 2    file2
#> 3    file3