#first set your working directory

library(raster)

bio1 <- raster("bio1.asc")
bio2 <- raster("bio2.asc")
bio3 <- raster("bio3.asc")
bio4 <- raster("bio4.asc")
bio5 <- raster("bio5.asc")
bio6 <- raster("bio6.asc")
bio7 <- raster("bio7.asc")
bio8 <- raster("bio8.asc")
bio9 <- raster("bio9.asc")
bio10 <- raster("bio10.asc")
bio11 <- raster("bio11.asc")
bio12 <- raster("bio12.asc")
bio13 <- raster("bio13.asc")
bio14 <- raster("bio14.asc")
bio15 <- raster("bio15.asc")
bio16 <- raster("bio16.asc")
bio17 <- raster("bio17.asc")
bio18 <- raster("bio18.asc")
bio19 <- raster("bio19.asc")
dem <- raster("dem.asc")
slope <- raster("slope2.asc")
aspect <- raster("aspect.asc")

#et cetera et cetera

#now you can resample your rasters to be exactly like your target raster
bio2b <- resample(bio2, bio1)
bio3b <- resample(bio3, bio1)
bio4b <- resample(bio4, bio1)
bio5b <- resample(bio5, bio1)
bio6b <- resample(bio6, bio1)
bio7b <- resample(bio7, bio1)
bio8b <- resample(bio8, bio1)
bio9b <- resample(bio9, bio1)
bio10b <- resample(bio10, bio1)
bio11b <- resample(bio11, bio1)
bio12b <- resample(bio12, bio1)
bio13b <- resample(bio13, bio1)
bio14b <- resample(bio14, bio1)
bio15b <- resample(bio15, bio1)
bio16b <- resample(bio16, bio1)
bio17b <- resample(bio17, bio1)
bio18b <- resample(bio18, bio1)
bio19b <- resample(bio19, bio1)
demb <- resample(dem, bio1)
aspectb <- resample(aspect, bio1)
slopeb <- resample(slope, bio1)



#et cetera et cetera

writeRaster(bio1, "bio1c.asc", overwrite = TRUE)
writeRaster(bio2b, "bio2c.asc", overwrite = TRUE)
writeRaster(bio3b, "bio3c.asc", overwrite = TRUE)
writeRaster(bio4b, "bio4c.asc", overwrite = TRUE)
writeRaster(bio5b, "bio5c.asc", overwrite = TRUE)
writeRaster(bio6b, "bio6c.asc", overwrite = TRUE)
writeRaster(bio7b, "bio7c.asc", overwrite = TRUE)
writeRaster(bio8b, "bio8c.asc", overwrite = TRUE)
writeRaster(bio9b, "bio9c.asc", overwrite = TRUE)
writeRaster(bio10b, "bio10c.asc", overwrite = TRUE)
writeRaster(bio11b, "bio11c.asc", overwrite = TRUE)
writeRaster(bio12b, "bio12c.asc", overwrite = TRUE)
writeRaster(bio13b, "bio13c.asc", overwrite = TRUE)
writeRaster(bio14b, "bio14c.asc", overwrite = TRUE)
writeRaster(bio15b, "bio15c.asc", overwrite = TRUE)
writeRaster(bio16b, "bio16c.asc", overwrite = TRUE)
writeRaster(bio17b, "bio17c.asc", overwrite = TRUE)
writeRaster(bio18b, "bio18c.asc", overwrite = TRUE)
writeRaster(bio19b, "bio19c.asc", overwrite = TRUE)
writeRaster(demb, "demc.asc", overwrite = TRUE)
writeRaster(slopeb, "slopec.asc", overwrite = TRUE)
writeRaster(aspectb, "aspectc.asc", overwrite = TRUE)


#et cetera et cetera et cetera