You should get rid of the quotes around your $x variable. It might work just fine like this but best practice says to not wrap variables in quotes. I Assume that $x gets filled somewhere earlier in your script because I do not see it getting filled with the actual folder you want to check in the code you posted.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.