Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(magrittr)
- library(stringr)
- print_dir_f <- function(pathName, layer){
- fileNames <- list.files(pathName)
- isdir <- file.info(fileNames)$isdir
- isdir[is.na(isdir)] <- FALSE
- for (i in seq_along(fileNames))
- {
- if (isdir[i])
- {
- str_c(rep(" ", layer), collapse = "") %>% str_c(fileNames[i], '\n') %>% cat
- str_c(pathName, fileNames[i], sep='/') %>% print_dir_f(layer+1)
- } else
- {
- str_c(rep(" ", layer), collapse = "") %>% str_c(fileNames[i], '\n') %>% cat
- }
- }
- }
- print_dir_f(".", 0)
Add Comment
Please, Sign In to add comment