Compress and Archive Files on Laptop
TODO - attr(); unlist();
knitr::opts_chunk$set(echo = TRUE, comment=" ##", error=TRUE, collapse=TRUE) load_all() library(jsonlite) library(data.table) library(magrittr) setwd("~/code/jimTools/rmd")
b <- fromJSON("~/Downloads/to_Drive/bookmarks-2022-08-24.json") str(b, max.level=1, vec.len=5) str(b$children, max.level=1, vec.len=2) # has 4 df str(b$children$children, max.level=1, vec.len=2) ## Looks like bookmark folder ... then child with all the bookmarks ## 1st table (bookmarksmenu?) 17 x 12 str(b$children$children[[1]], max.level=1, vec.len=5) df1 <- data.table(b$children$children[[1]]) df1 |> head() ## 2nd (toolbar) str(b$children$children[[2]], max.level=1, vec.len=5) str(b$children$children[[2]]$children[[7]]$children[[1]], max.level=1, vec.len=1) df2 <- data.table(b$children$children[[2]]) df2[, .(title)] ## multiple levels ! to get to Bayes str(b$children$children[[2]]$children[[7]]$children[[1]], max.level=1, vec.len=1) ## next level { ## grab milf df2[title == "mlif"] mlif_db <- df2[title == "mlif"]$children mlif_db <- df2[title == "mlif"]$children[[1]] ## this is it. mlif_db is.data.frame(mlif_db) # [1] TRUE is.data.table(mlif_db) # [1] FALSE mlif_db <- data.table(mlif_db) str(mlif_db) length(mlif_db) mlif_db[[1]] |> head() mlif_db[[2]] |> head() mlif_db[[3]] |> head() # yes! mlif_db[, .(index,title)] } ## 3rd (unfiled) str(b$children$children[[3]], max.level=1, vec.len=5) df3 <- data.table(b$children$children[[3]]) head(df3) ## 4th (mobile) str(b$children$children[[4]], max.level=1, vec.len=5)
file <- "001_compress_files.Rmd" file <- basename(file) dir="rmd" jimTools::ren_pdf(file,dir) jimTools::ren_github(file, dir)
dir <- "~/Downloads/documents" dir
prefix <- get_prefix() prefix
out_file <- get_compressed_file_name(prefix, dir) out_file
jr_compress_dir()
compress_dir(prefix, out_file, type="system", dir) # dir = directory (under project root) jr_compress_dir(type = "project", dir = "rmd") jr_compress_dir(type = "project", dir = "R")
output_dir <- "~/Downloads/toGoogle" output_dir <- here("rmd") dir <- here("~/Downloads/documents") # to backup out_file <- "test_compress.tar.gz" tar( tarfile = paste0(output_dir, "/", out_file), files = dir, compression = c("gzip"), extra_flags = "-X rmd/exclude_files.txt" )
TODO develop code HERE when good, put into compress.R
Problems: exclude/include certain files ?
# full list the_dirs = list( bin = "~/bin/*.sh", mp3 = "~/Downloads/mp3", # scripts onl #dotfiles = "~/dotfiles/.Renviron", documents = "~/Downloads/documents" # multiple dirs )
# pluck 1 dir at a time from the_dirs dir = the_dirs[[3]] dir compress_dir(type="system", dir = dir )
# To inspect tar.gz # tar doesn't like files in quotes tar --list -f <file>
knitr::knit_exit()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.