fix error when files is directory