It's because you have surrounded the path with backticks (``) in the "if" line. That's telling the shell to execute the file (and no doubt many of the files in the folder aren't executable - hence the error). Switch to ordinary quotes.
As an aside, using backticks to capture the output of "ls" in the "for" loop is a bad idea - it will break on filenames that contain spaces (which are perfectly legal).