This is an R function I wrote in order to reclassify 120 6MB raster tiff files showing standardised precipitation index data for the UK on a 5x5km grid (supplied by the Centre for Hydrology and Ecology, UK). The function took around 45sec to run on a high-spec desktop PC.

#import required libraries
library(raster)
library(rgdal)

#get the list of rasters
#--pattern = "*.tif$"-- ensures only main tif files are selected and avoids error when
#reading rasters by skipping any associated aux/world files
grids <- list.files("./Data/Rasters/", pattern = "*.tif$")

#generate a reclassification matrix 
#in this example, values less that -2 are assigned a new value of '1' ('severe to extreme drought')
#and values greater than -2 assigned a new value of 0 (less then 'severe drought')
m <- c(-999, -2, 1,  -2, 999, 0)
rclmat <- matrix(m, ncol=3, byrow=TRUE)

#function to reclassify rasters and write a new reclassified tif file for each
batch_reclass <- function(grids){
for (i in 1:length(grids)) {
#read in raster
r <- raster(paste0("./Data/Rasters/", grids[i]))
#perform the reclassifcation
rc <- reclassify(r, rclmat)
#write each reclass to a new file 
writeRaster(rc, filename = paste0("./Data/Reclass/", "rc_", grids[i]), format="GTiff", overwrite=TRUE)
  }
}
#run the function
batch_reclass(grids)