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?

1 answer

  • answered 2022-05-06 15:46 Quinten

    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)
    

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum