From b2f36a1cfc26306d40be12bb76b96c50f2415ba5 Mon Sep 17 00:00:00 2001 From: hadley Date: Mon, 21 Nov 2016 08:28:57 -0600 Subject: [PATCH] Copy for creating figures dir (For book export) --- .gitignore | 1 + figures.R | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 figures.R diff --git a/.gitignore b/.gitignore index 14cd118..0c45146 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ libs _main.* bookdown* tmp-pdfcrop-* +figures diff --git a/figures.R b/figures.R new file mode 100644 index 0000000..87f94ea --- /dev/null +++ b/figures.R @@ -0,0 +1,18 @@ +library(stringr) +library(purrr) + +chapters <- dir("_bookdown_files", full.names = TRUE, pattern = "_files$") + +figures <- dir(chapters, full.names = TRUE, pattern = "-latex") + +name <- figures %>% + dirname() %>% + basename() %>% + str_replace("_files", "") + +out_path <- file.path("figures", name) + +dir.create("figures/") +out_path %>% walk(dir.create) + +map2(figures, out_path, ~ file.copy(dir(.x, full.names = TRUE), .y))