setwd("C:/Explore/r-basics") getwd() dir.exists("C:/Explore/r-basics/Data") list.files("C:/Explore/r-basics") list.files("C:/Explore/r-basics/Data") file.exists("C:/Explore/r-basics/Data/class_x.rdata") list.files (pattern = '\\.*R', recursive=TRUE) list.files (pattern = '\\.ipynb', recursive=TRUE) #file.copy.R #identify the folders fromFolder <- "H:/R/cis_study" toFolder <- "F:/cis_study_backup" # find the list of files to copy list.of.files <- list.files(fromFolder, ".R$") # print objects print(c(fromFolder, toFolder, list.of.files)) options(warn=1) # copy the files to the toFolder # clear memory rm(list = ls() ) setwd("H:/") getwd library(Hmisc) dd<-read.table(text="CTFIP Hispanic NonHispanic 6001 323307 1154673 6003 63 1113 6005 4566 33761 6007 29512 189123 6009 4595 41399 6011 11136 10029", header=T) sink("contents_dd.txt") contents(dd) sink() setwd ("H:/R/cis_study") library(Hmisc) load("xd02_13.rdata") sink ("contents_cis.txt") # sink the output to a connection contents(xd02_13) sink() # stop sinking so that the output (if any) goes to the R console #file.copy.R #identify the folders fromFolder <- "H:/R/cis_study" toFolder <- "F:/cis_study_backup" # find the list of files to copy list.of.files <- list.files(fromFolder, ".R$") setwd ("L:/Stata_Resources") list.files(pattern="^", full.names = TRUE, ignore.case = TRUE) #This works # print objects print(c(fromFolder, toFolder, list.of.files)) options(warn=1) # copy the files to the toFolder file.copy(file.path(fromFolder,list.of.files), toFolder, overwrite=TRUE) setwd ("C:/Data") sink("C:/bdata/file_list.txt") options(width=132) Sys.glob("*.sas") # returns a sorted list of files sink()