Print the directory structure of a given path in a tree-like format using ASCII characters for maximum compatibility across different systems. Optionally, save the result to a log file for record keeping or debugging.
Usage
file_tree(
path = ".",
max_depth = 2,
verbose = TRUE,
log = FALSE,
log_path = NULL,
file_name = NULL,
append = FALSE
)Arguments
- path
Character. The target root directory path to print. Default is ".".
- max_depth
Integer. Maximum depth of recursion into subdirectories. Default is 2.
- verbose
Logical. Whether to print the tree to console. Default is TRUE.
- log
Logical. Whether to save the tree output as a log file. Default is FALSE.
- log_path
Character. Directory path to save the log file if log = TRUE. Default is tempdir().
- file_name
Character. Custom file name for the log file. If NULL, a name like "file_tree_YYYYMMDD_HHMMSS.log" will be used.
- append
Logical. If TRUE, appends to an existing file (if present). If FALSE, overwrites the file. Default is FALSE.
Examples
# Basic usage with current directory:
file_tree()
#>
#> ── Directory Tree: F:\project\evanverse\docs\reference ─────────────────────────
#> +-- any_void.html
#> +-- bio_palette_gallery.html
#> +-- check_pkg.html
#> +-- clear_palette_cache.html
#> +-- cols_with_void.html
#> +-- comb.html
#> +-- combine_logic.html
#> +-- compile_palettes.html
#> +-- convert_gene_id.html
#> +-- create_palette.html
#> +-- df2list.html
#> +-- df_forest_test.html
#> +-- download_batch.html
#> +-- download_gene_ref.html
#> +-- download_geo_data.html
#> +-- download_url.html
#> +-- drop_void.html
#> +-- figures
#> | +-- logo-input.png
#> | +-- logo.png
#> +-- file_info.html
#> +-- file_tree.html
#> +-- get_ext.html
#> +-- get_palette.html
#> +-- gmt2df.html
#> +-- gmt2list.html
#> +-- grapes-is-grapes.html
#> +-- grapes-map-grapes.html
#> +-- grapes-match-grapes.html
#> +-- grapes-nin-grapes.html
#> +-- grapes-p-grapes.html
#> +-- hex2rgb.html
#> +-- index.html
#> +-- inst_pkg.html
#> +-- is_void.html
#> +-- libs
#> | +-- core-js-2.5.3
#> | +-- htmlwidgets-1.6.4
#> | +-- react-18.2.0
#> | +-- reactable-0.4.4
#> | +-- reactable-binding-0.4.4
#> | +-- reactwidget-2.0.0
#> +-- list_palettes.html
#> +-- logs
#> | +-- palettes
#> +-- map_column.html
#> +-- palette_cache_info.html
#> +-- perm.html
#> +-- pkg_functions.html
#> +-- pkg_management.html
#> +-- pkg_version.html
#> +-- plot_bar.html
#> +-- plot_density.html
#> +-- plot_forest.html
#> +-- plot_pie.html
#> +-- plot_venn-1.png
#> +-- plot_venn-2.png
#> +-- plot_venn-3.png
#> +-- plot_venn-4.png
#> +-- plot_venn-5.png
#> +-- plot_venn.html
#> +-- preview_palette-1.png
#> +-- preview_palette-2.png
#> +-- preview_palette-3.png
#> +-- preview_palette.html
#> +-- print.quick_ttest_result.html
#> +-- quick_ttest-1.png
#> +-- quick_ttest-2.png
#> +-- quick_ttest.html
#> +-- read_excel_flex.html
#> +-- read_table_flex.html
#> +-- reload_palette_cache.html
#> +-- remind.html
#> +-- remove_palette.html
#> +-- replace_void.html
#> +-- rgb2hex.html
#> +-- rows_with_void.html
#> +-- safe_execute.html
#> +-- scale_color_evanverse.html
#> +-- scale_colour_evanverse.html
#> +-- scale_evanverse-1.png
#> +-- scale_evanverse-2.png
#> +-- scale_evanverse-3.png
#> +-- scale_evanverse-4.png
#> +-- scale_evanverse-5.png
#> +-- scale_evanverse-6.png
#> +-- scale_evanverse-7.png
#> +-- scale_evanverse.html
#> +-- scale_fill_evanverse.html
#> +-- set_mirror.html
#> +-- summary.quick_ttest_result.html
#> +-- trial.html
#> +-- update_pkg.html
#> +-- view.html
#> +-- void.html
#> +-- with_timer.html
#> +-- write_xlsx_flex.html
file_tree(".", max_depth = 3)
#>
#> ── Directory Tree: F:\project\evanverse\docs\reference ─────────────────────────
#> +-- any_void.html
#> +-- bio_palette_gallery.html
#> +-- check_pkg.html
#> +-- clear_palette_cache.html
#> +-- cols_with_void.html
#> +-- comb.html
#> +-- combine_logic.html
#> +-- compile_palettes.html
#> +-- convert_gene_id.html
#> +-- create_palette.html
#> +-- df2list.html
#> +-- df_forest_test.html
#> +-- download_batch.html
#> +-- download_gene_ref.html
#> +-- download_geo_data.html
#> +-- download_url.html
#> +-- drop_void.html
#> +-- figures
#> | +-- logo-input.png
#> | +-- logo.png
#> +-- file_info.html
#> +-- file_tree.html
#> +-- get_ext.html
#> +-- get_palette.html
#> +-- gmt2df.html
#> +-- gmt2list.html
#> +-- grapes-is-grapes.html
#> +-- grapes-map-grapes.html
#> +-- grapes-match-grapes.html
#> +-- grapes-nin-grapes.html
#> +-- grapes-p-grapes.html
#> +-- hex2rgb.html
#> +-- index.html
#> +-- inst_pkg.html
#> +-- is_void.html
#> +-- libs
#> | +-- core-js-2.5.3
#> | | +-- LICENSE
#> | | +-- package.json
#> | | +-- shim.min.js
#> | +-- htmlwidgets-1.6.4
#> | | +-- htmlwidgets.js
#> | +-- react-18.2.0
#> | | +-- AUTHORS
#> | | +-- LICENSE.txt
#> | | +-- react-dom.min.js
#> | | +-- react.min.js
#> | +-- reactable-0.4.4
#> | | +-- reactable.css
#> | | +-- reactable.js
#> | | +-- reactable.js.map
#> | | +-- reactable.server.js
#> | | +-- reactable.server.js.LICENSE.txt
#> | | +-- reactable.server.js.map
#> | | +-- reactable.yaml
#> | +-- reactable-binding-0.4.4
#> | | +-- reactable.js
#> | +-- reactwidget-2.0.0
#> | +-- react-tools.js
#> +-- list_palettes.html
#> +-- logs
#> | +-- palettes
#> | +-- create_palette.log
#> +-- map_column.html
#> +-- palette_cache_info.html
#> +-- perm.html
#> +-- pkg_functions.html
#> +-- pkg_management.html
#> +-- pkg_version.html
#> +-- plot_bar.html
#> +-- plot_density.html
#> +-- plot_forest.html
#> +-- plot_pie.html
#> +-- plot_venn-1.png
#> +-- plot_venn-2.png
#> +-- plot_venn-3.png
#> +-- plot_venn-4.png
#> +-- plot_venn-5.png
#> +-- plot_venn.html
#> +-- preview_palette-1.png
#> +-- preview_palette-2.png
#> +-- preview_palette-3.png
#> +-- preview_palette.html
#> +-- print.quick_ttest_result.html
#> +-- quick_ttest-1.png
#> +-- quick_ttest-2.png
#> +-- quick_ttest.html
#> +-- read_excel_flex.html
#> +-- read_table_flex.html
#> +-- reload_palette_cache.html
#> +-- remind.html
#> +-- remove_palette.html
#> +-- replace_void.html
#> +-- rgb2hex.html
#> +-- rows_with_void.html
#> +-- safe_execute.html
#> +-- scale_color_evanverse.html
#> +-- scale_colour_evanverse.html
#> +-- scale_evanverse-1.png
#> +-- scale_evanverse-2.png
#> +-- scale_evanverse-3.png
#> +-- scale_evanverse-4.png
#> +-- scale_evanverse-5.png
#> +-- scale_evanverse-6.png
#> +-- scale_evanverse-7.png
#> +-- scale_evanverse.html
#> +-- scale_fill_evanverse.html
#> +-- set_mirror.html
#> +-- summary.quick_ttest_result.html
#> +-- trial.html
#> +-- update_pkg.html
#> +-- view.html
#> +-- void.html
#> +-- with_timer.html
#> +-- write_xlsx_flex.html
# \donttest{
# Example with temporary directory and logging:
temp_dir <- tempdir()
file_tree(temp_dir, max_depth = 2, log = TRUE, log_path = tempdir())
#>
#> ── Directory Tree: C:\Users\84241\AppData\Local\Temp\RtmpkVdn5s ────────────────
#> +-- Rf41e0f5d17e7
#> +-- bslib-4c3ed0bf4230f5c21352bfea2ee79d53
#> | +-- bootstrap.bundle.min.js
#> | +-- bootstrap.bundle.min.js.map
#> | +-- bootstrap.min.css
#> +-- downlit
#> | +-- Biobase
#> | +-- base
#> | +-- cli
#> | +-- covr
#> | +-- curl
#> | +-- devtools
#> | +-- ggplot2
#> | +-- grDevices
#> | +-- pkgdown
#> | +-- remotes
#> | +-- reprex
#> | +-- stats
#> | +-- testthat
#> | +-- utils
#> +-- file41e0157d2e64
#> +-- file41e01dd870bd
#> +-- file41e0273c44f3
#> +-- file41e02a825a7
#> +-- file41e031d5d63
#> | +-- font.css
#> | +-- tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTN1OVgaY.woff2
#> | +-- tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTNFOVgaY.woff2
#> | +-- tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTNVOVgaY.woff2
#> | +-- tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTOVOVgaY.woff2
#> | +-- tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTOlOV.woff2
#> | +-- tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxTPlOVgaY.woff2
#> +-- file41e03bd151b2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiA.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZBhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZFhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZJhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZNhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZthiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZxhiI2B.woff2
#> | +-- font.css
#> +-- file41e03e03ce0
#> +-- file41e044407651
#> +-- file41e05d1b3c7e
#> +-- file41e06bf16d58
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiA.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZBhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZFhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZJhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZNhiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZthiI2B.woff2
#> | +-- UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZxhiI2B.woff2
#> | +-- font.css
#> +-- file41e0716e5af1
#> +-- file41e079937433
#> +-- logs
#> | +-- palettes
#> +-- palettes.rds
#> +-- robots.txt
#> ✔ File tree log saved to: C:\Users\84241\AppData\Local\Temp\RtmpkVdn5s\file_tree_20251112_173639.log
# }
