I want to search and replace some file paths in text files.
on average the my file size is above 2 GB.
i have a folder in my D drive "D:\LargeFilesFolder".
and all files exist in the folder.
Iterate over the lines and write a new file. Then move the new file over the old file.
with open(outputfilename, "w") as outputfile: with open(inputfilename, "r") as inputfile: for line in inputfile: # replace in line and write to outputfile shutil.move(outputfilename, inputfilename)