Using purrr:map for looping and simultaneously perform operation on each loop

Also, you can read all files directly into a single dataframe using the .id parameter to capture the filename and create the year column afterwards.

library(tidyverse)
library(stringr)

list_of_files <- list.files(pattern = ".csv$",
                            full.names = TRUE)
df <- list_of_files %>%
    setNames(nm = .) %>% 
    map_dfr(read.csv2, .id = "file_name") %>% 
    mutate(Year = str_extract(file_name, "\\d{4}"))
5 Likes