Update escaping for file names to handle files with single quotes

It took me a couple of tries to get it right, but I've been using this code for a year now without a problem.