How to get object from path name?

Hi, Could I use this structure to identify folder paths? I want to alert a warning if any used assets come from a folder named anything like “test” folder. If it has “test” in its name.