The fastest way to import and edit data in R
1) Firstly you could use fread from data.table to speed up reading of .csv files.

2) It looks like that you do not need the two inner loops, you could do that with vectorization.

If you could provide some example data of df and df_names(using dput) then I could write the necessary code, and test the timings...



Update:

It looks like for smaller files (200 cols and 2000 rows) read_csv2 from readr is faster than data.table's fread:

Unit: milliseconds
                                                               expr      min       lq     mean   median       uq      max neval cld
 read.csv(tempPath, skip = 5, header = FALSE, sep = ";", dec = ",") 475.7547 480.2411 488.7772 484.3644 487.7255 515.8005     5   c
                                      read_csv2(tempPath, skip = 4) 179.2461 181.9832 182.2904 182.3569 182.4955 185.3702     5 a  
                               fread(tempPath, skip = 4, dec = ",") 463.4811 468.1232 470.4556 468.3920 469.5664 482.7155     5  b 


You should test it yourself and see if there is significant difference.

The end code could look something like this:

files_data &lt;- list.files(path_data, full.names = T)
files_data

files_data &lt;- grep(".csv", files_data, value = T, fixed = T)
length(files_data)

files_data # paths to files


myAproach &lt;- function(i) {
  require(readr)
  tempPath &lt;- files_data[i]
  name &lt;- basename(tempPath)
  name &lt;- gsub('-', '_', substr(name, start = 0,
                                stop = (nchar(name) - 4)),
               fixed = T)
  print(name)

  df &lt;- read_csv2(tempPath, skip = 4)

  dfnames_test_MS7 &lt;- colnames(df)
  dfnames_test_MS7[1] &lt;- "DateTime"
  dfnames_test_MS7 &lt;- gsub('V', 'x', dfnames_test_MS7, fixed = T)
  #fixed for speed
  colnames(df) &lt;- dfnames_test_MS7
  df
}
resDflist &lt;- lapply(1:length(files_data), myAproach)


resDflist is list of data.frames. In my opinion it is easier to work with lists than assign the data.frames to global environment.