Python - Using str.replace with a wildcard

Viewed 34162

I'm trying to rename folder names named with this pattern: FOLDERNAME (###)

I'm trying to get rid of (###), a series of numbers of random length.

I would like to use str.replace as show below to do it, but I'm not sure I can use a wildcard this way...

folderdir = os.listdir(path)            # Listing the folder names
for foldername in folderdir:
    output = foldername.replace("(*)", "")
    rename()
2 Answers
Related