'renaming a 7zip extracted folder error Access i denied R

I extracted a TxtinOut named folder using the following cmd in R

shell('7z x D:/Region02/test.7z  -oD:/Region02 -r -y')

I want to rename this folder TxtinOut to New_Name. I tried file.rename() but faced an ERROR: reason 'Access is denied'

file.rename("D:\\Region02\\TxtinOut", "D:\\Region02\\New_Name")

Can anyone suggest how I can proceed?



Solution 1:[1]

Make sure you are in the right directory setwd("right directory") and that the files exist which you can check by using list.files or file.exists. You can use this code to rename your file:

from <- c("TxtinOut")
to <- c("New_Name")

file.rename(from, to)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Quinten