Use the find command in SHELL script and store the out put in one variable, and the variable out put to take necessary action in the If condition

In this case you can use the power of FIND command and achieve what you want.