pattern searching directory and codes