Move files to new subdirectories based on filename
Posted on 2010-01-08
I have file with following filenames:
ppt1988_001 ... ppt1988_500 ... ppt2004_500
tmin1988_001 ... tmin1988_500 ... tmin2004_500
tmax1988_001 ... tmax1988_500 ... tmax2004_500
So they have the base in front ppt, tmax, or tmin. Then this is followed by a year 1988 (through 2004) and then a three digit number 001 ~ 500 with some missing values. There are 7 files of the same base name each with a different extension.
I would like a script to move the files into new subdirectories (they need to be created) for each of the year/ppt, tmax, or tmin combos.
For example, one new subdirectory (ppt1988) would contain all files with the name ppt1988 (7 extensions * ~500). etc