It has always been my problem having to set permissions of files or folders selectively unitl I found a post in movabletripe.com. This trick is invaluable that I decided to repost it on this site as a backup.
find . -type d -exec chmod 755 {} \;
This will recursively search your directory tree (starting at dir ‘dot’) and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;
Please visit the original post.