'replace confignames with the real thing'

def doReplace(self, string, replacements, remove_multiple=False, folder=False):

    replacements = replacements.copy()
    if remove_multiple:
        replacements['cd'] = ''
        replacements['cd_nr'] = ''
    replaced = toUnicode(string)
    for (x, r) in replacements.items():
        if (x in ['thename', 'namethe']):
            continue
        if (r is not None):
            replaced = replaced.replace((six.u('<%s>') % toUnicode(x)), toUnicode(r))
        else:
            replaced = replaced.replace((('<' + x) + '>'), '')
    if self.conf('replace_doubles'):
        replaced = self.replaceDoubles(replaced.lstrip('.    '))
    for (x, r) in replacements.items():
        if (x in ['thename', 'namethe']):
            replaced = replaced.replace((six.u('<%s>') % toUnicode(x)), toUnicode(r))
    replaced = re.sub('[\\x00:\\*\\?\\"<>\\|]', '', replaced)
    sep = (self.conf('foldersep') if folder else self.conf('separator'))
    return ss(replaced.replace('    ', ('    ' if (not sep) else sep)))
