Skip to content

Commit b2f36a1

Browse files
committed
Copy for creating figures dir
(For book export)
1 parent 4dd8bb4 commit b2f36a1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ libs
1212
_main.*
1313
bookdown*
1414
tmp-pdfcrop-*
15+
figures

figures.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
library(stringr)
2+
library(purrr)
3+
4+
chapters <- dir("_bookdown_files", full.names = TRUE, pattern = "_files$")
5+
6+
figures <- dir(chapters, full.names = TRUE, pattern = "-latex")
7+
8+
name <- figures %>%
9+
dirname() %>%
10+
basename() %>%
11+
str_replace("_files", "")
12+
13+
out_path <- file.path("figures", name)
14+
15+
dir.create("figures/")
16+
out_path %>% walk(dir.create)
17+
18+
map2(figures, out_path, ~ file.copy(dir(.x, full.names = TRUE), .y))

0 commit comments

Comments
 (0)