You could name mylist
with the names you already have in fnames
.
names(mylist) <- tools::file_path_sans_ext(fnames)
mylist
file_path_sans_ext
remove extension from the filenames.
If you want to rename anything in the file name (for example N1 any text.xlsx), you could use
names(mylist) <- tools::file_path_sans_ext(str_remove(fnames, " any text"))
mylist
Or even:
names(mylist) <- tools::file_path_sans_ext(str_replace(fnames, " any text", "other text"))
mylist
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…