Only reexport from fs

extract_dir(x)

extract_ext(x)

extract_file(x)

Arguments

x

character of one or more paths

Value

character

Functions

  • extract_dir: extract directory path

  • extract_ext: extract filename

  • extract_file: extract file extension

See also

To fix information from paths see str_helpers

Other path: str_helpers

Examples

messy_paths
#> [1] "Big_one/folder-foo/file_n.jpg" "folder-foo/File n.jpg" #> [3] "folder-foo2/file 5.jpg" "file.txt" #> [5] "file.jpeg" "file.png" #> [7] "file.mom"
messy_paths %>% extract_dir()
#> [1] "Big_one/folder-foo" "folder-foo" "folder-foo2" #> [4] "." "." "." #> [7] "."
messy_paths %>% extract_file()
#> [1] "file_n.jpg" "File n.jpg" "file 5.jpg" "file.txt" "file.jpeg" #> [6] "file.png" "file.mom"
messy_paths %>% extract_ext()
#> [1] "jpg" "jpg" "jpg" "txt" "jpeg" "png" "mom"
# all of this in a tibble tibble::tibble(paths = messy_paths, dir = extract_dir(paths), file = extract_file(paths), ext = extract_ext(paths))
#> # A tibble: 7 x 4 #> paths dir file ext #> <chr> <chr> <chr> <chr> #> 1 Big_one/folder-foo/file_n.jpg Big_one/folder-foo file_n.jpg jpg #> 2 folder-foo/File n.jpg folder-foo File n.jpg jpg #> 3 folder-foo2/file 5.jpg folder-foo2 file 5.jpg jpg #> 4 file.txt . file.txt txt #> 5 file.jpeg . file.jpeg jpeg #> 6 file.png . file.png png #> 7 file.mom . file.mom mom