import os
from pathlib import Path


def main(base_dir):
    path = Path(base_dir)
    target = path.joinpath('Kopfzeilen')
    os.makedirs(target, exist_ok=True)

    for filename in Path(base_dir).glob('*.csv'):
        with open(filename, 'r', encoding='latin-1') as frh, open(target.joinpath(filename.name), 'w', encoding='latin-1') as fwh:
            fwh.write(frh.readline())


if __name__ == '__main__':
    main('C:/GlobalCube/System/OPTIMA/Export')
