Skip to content

Commit

Permalink
Copy for creating figures dir
Browse files Browse the repository at this point in the history
(For book export)
  • Loading branch information
hadley committed Nov 21, 2016
1 parent 4dd8bb4 commit b2f36a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 12,4 @@ libs
_main.*
bookdown*
tmp-pdfcrop-*
figures
18 changes: 18 additions & 0 deletions figures.R
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit b2f36a1

Please sign in to comment.