1、单线程loop
### 1、check Files
data.use[["Permision"]] <- unlist(lapply(data.use[["Path"]],function(x) R.utils::fileAccess(pathname = x, mode=4)))
data.use[["DIR_Size"]] <- unlist(lapply(data.use[["Path"]],function(x) strsplit(suppressWarnings(toString(system(paste('du -BG ',x,sep = " "), ignore.stderr = T ,intern = T))),"\t")[[1]][1]))
### 2、summary
cat("Total Size: ",sum(as.numeric(gsub("G","",data.use[["DIR_Size"]])),na.rm = T)/1024,"T","\n")
cat("Permission ERR: ",sum(abs(data.use[["Permision"]])),"\n")
2、多线程loop
library(future.apply);plan('multisession', workers = 20);options(future.globals.maxSize = 100 * 1024^3)
data.use <- readxl::read_xlsx(</your file/>) %>% mutate(Path = </rename column/>)
### 1、check Files
data.use[["Permision"]] <- unlist(future_lapply(data.use[["Path"]],function(x){R.utils::fileAccess(pathname = x, mode=4)}))
data.use[["DIR_Size(M)"]] <- unlist(future_lapply(data.use[["Path"]],function(x){strsplit(suppressWarnings(toString(system(paste('du -BM ',x,sep = " "), ignore.stderr = T ,intern = T))),"\t")[[1]][1]}))
data.use[["DIR_Size(G)"]] <- paste0(round(as.numeric(gsub("M","",data.use[["DIR_Size(M)"]]))/1024,2),"G")
data.use[["DIR_Size(T)"]] <- paste0(round(as.numeric(gsub("M","",data.use[["DIR_Size(M)"]]))/(1024^2),2),"T")
### 2、summary
cat("Total Size: ",sum(as.numeric(gsub("G","",data.use[["DIR_Size(G)"]])),na.rm = T)/1024,"T","\n")
cat("Permission ERR: ",sum(abs(data.use[["Permision"]])),"\n")
### 3、...save output
data.use %>% write.table(</output file/>,sep = "\t",col.names = T,row.names = F,quote = F)