Skip to content

Instantly share code, notes, and snippets.

@erikgregorywebb
Created December 22, 2018 17:26
Show Gist options
  • Save erikgregorywebb/66d617a8068bd35d6fdbe8d3e702a90e to your computer and use it in GitHub Desktop.
Save erikgregorywebb/66d617a8068bd35d6fdbe8d3e702a90e to your computer and use it in GitHub Desktop.
# count the number of files and folders
years <- c('2010', '2011', '2012', '2013', '2014', '2015', '2016', '2017', '2018')
directory <- '/Users/erikgregorywebb/Documents/Python/runtwolf/R/'
for (i in 1:length(years)) {
file_count = 0
setwd(paste(directory, years[i], '/XC', sep = ""))
folders <- list.files()
for (j in 1:length(folders)) {
setwd(paste(directory, years[i], '/XC/', folders[j], sep = ""))
files <- list.files()
file_count = file_count + length(files)
}
print(paste(years[i], file_count, length(folders), sep = " "))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment