updated the script. We can now change to a directory with given pattern.