I have a folder with thousands of files respecting the following naming scheme:
Each components of the files names (institute, model, scenario, river) are variables.
Then, I would like to sort and classify those files by the name of each variables exept
Therefore, each institute name should be used to create a corresponding directory. These directories should be composed of sub-directories named accordingly with different 'model' names.
To be more accurate I would like to provide a small example, considering the following files:
wbm_gfdl_rcp4_mississippi.txt matsiro_gfdl_rcp8_amazon.txt wbm_miroc_rcp8_niger.txt
I would like to create a
'wbm' directory having the sub-directories
'gfdl' (containing the following file
'miroc' (containing the following file
'wbm_miroc_rcp8_niger.txt'). And a
'matsiro' directory having just a
'gfdl' sub-directory (containing
Considering the huge amount of files, I don't really know from where to start!