My first aim was to replace all commas in all text files in a directory with space. (To work on them easily. I have 100 text files.)

I first took all the data as string, then applied the code below. It works. However, I am bit lack of knowledge about how to save those changes in all text files, in my actual folder.

Thank you for any help and recommendations.

The code;

```
from pathlib import Path
from os import listdir
from os.path import isfile, join

path = "/folder"
only_files = [f for f in listdir(path) if isfile(join(path, f))]
all_lines = []
for file_name in only_files:
    file_path = Path(path) / file_name
    with open(file_path, 'r') as f:
        file_content = f.read()
        file_content = file_content.replace(",", " ")
        all_lines.append(file_content.splitlines())
        print(file_content)

```