I have a folder with over 1000 pdf files, like class1_try1Q2022.pdf...class1050_try1Q2022.pdf. I want to remove 'try' from the file name and change all files to class1_1Q2022.pdf...class1050_1Q2022.pdf. How to do it? Thanks in advance
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".
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.