Fixed sanitising --file-prefix and --subdir-format

Sanitise path components individually, not full path