How can I regrid all nc files in a folder?
Added by Cat Fitz over 3 years ago
I have a bunch of Terraclimate .nc files in folders that I want to regid. I want to automate this so I don't have to do it manually.
I have tried this:
for i in $(ls);do cdo remapcon,r2160x1080 ${i} regrid/${i}WC.nc; done
But received this error:
Error (cdf_create): regrid/TerraClimate_ppt_1982.nc: Permission denied
cdf_create : ncid = -1 mode = 4352 chunksizehint = 0 file = regrid/TerraClimate_ppt_1982WC.nc
Can anyone tell me what I am doing wrong? Why would permission be denied for me to create a netcdf file?
Many thanks.
Replies (1)
RE: How can I regrid all nc files in a folder? - Added by Karin Meier-Fleischer over 3 years ago
Hi Cat,
I think that is not a CDO problem. Does the directory regrid already exist? If you do a $(ls) directories will be used too, so it would be better to list only the relevant files with $(ls TerraClimate*.nc).
In a script file you can do e.g.
mkdir -p regrid for i in $(ls TerraClimate*.nc); do cdo remapcon,r2160x1080 ${i} regrid/${i}WC.nc; done
or
mkdir -p regrid; for i in $(ls TerraClimate*.nc); do cdo remapcon,r2160x1080 ${i} regrid/${i}WC.nc; done
-Karin