A quick piece of code that reads a text file, changes something, saves a new text file, and iterates that process for every text file in that folder.

setwd("path to the text files")

all_files = Sys.glob("*.txt")

for(i in 1:length(all_files)){

data = all_files[i]
}
Bo$$^2$$m =)