From a vector of given file paths, this function generates short and unique identifiers for files and folders. The assignements between identifiers and original paths are stored in two data frames, files and folders that are returned.

to_file_database(files, remove_common_base = TRUE)

Arguments

files

vector of file paths

remove_common_base

if TRUE (default) the common root of all files is removed before creating the database

Value

list of two data frames, files and folders

Examples

paths <- c(
  "very_long/very_ugly_path/even with spaces.doc",
  "very_long/very_ugly_path/even with spaces.docx"
)

to_file_database(paths)
#> Splitting paths ... ok. (0.00s) 
#> Removing the first 1 path segments ... ok. (0.00s) 
#> $files
#>   file_id             file_name folder_id
#> 1 file_01  even with spaces.doc folder_01
#> 2 file_02 even with spaces.docx folder_01
#> 
#> $folders
#>   folder_id    folder_path
#> 1 folder_01 very_ugly_path
#> 
to_file_database(paths, remove_common_base = FALSE)
#> $files
#>   file_id             file_name folder_id
#> 1 file_01  even with spaces.doc folder_01
#> 2 file_02 even with spaces.docx folder_01
#> 
#> $folders
#>   folder_id              folder_path
#> 1 folder_01 very_long/very_ugly_path
#>