Fix chmod command where filename includes spaces

Also try to enforce filename regex.