Extract metadata from folder names


#1

Hi, can anyone help get the “extract metadata from folder names” started, i am familiar with extraction from file names and the regular expression that goes with it, but i cannot get it to work to folder names, especially that i have many subfolders

so my folders are organised as such
experiment\animal name\tissue or organ\region\area[1-3]\field[0-15]

add to that the folder location which appears prior to folders and subfolders

thanks


#2

Hi @esmat, I recommend visiting regex101.com whenever you need to find a regular expression; it has an interactive text field that highlights a test string. Make sure you select “python” for the regular expression language.

For your test string I propose the following: (?P<experiment>.+)[\\/](?P<animal_name>.+)[\\/](?P<tissue_or_organ>.+)[\\/](?P<region>.+)[\\/]area(?P<area>\d+)[\\/]field(?P<field>\d+)$

I hope this helps. Thanks!


#3

that’s great help, thanks