One way of doing that is as follows.
- Choose all files that you want to convert by using
choose.files(), and store the names of the chosen file in an object.
oldnames <- choose.files() #pick the files class1_try1Q2022.pdf...etc in the directory
- Create new names by removing "try" using
gsub()
newnames <- gsub("try", "", oldnames)
- Rename the files by using
file.rename()
file.rename(oldnames, newnames)
You should now have had your files renamed with new names that do not contain "try".