Skip to content
Back to formatted view

Raw Message

Message-ID: <0BAD9F2E-2A01-4AFA-B5D4-7A39B49D30ED@utoronto.ca>
Date: 2016-04-16T19:44:22Z
From: Boris Steipe
Subject: How to delete Locked files in Mac
In-Reply-To: <CA+dpOJm4+cgGKMLZSy7Po2P=kmbJQJuj2HHWJEcahoD7tr94CA@mail.gmail.com>

The command:

   system("chflags -R nouchg /path/to/your/directory")

... should unlock your files recursively in the directory. Then proceed with 
file.remove()

B.



On Apr 16, 2016, at 3:09 PM, Christofer Bogaso <bogaso.christofer at gmail.com> wrote:

> Hi,
> 
> I am looking for some R code, which will delete all files in a Folder
> that contains both Locked and Unlocked files. There are many,
> therefore i would like to delete all files programmatically in one go.
> 
> I used following code :
> 
> ## "SS" is the Folder name including entire path which contains Locked
> and Unlocked files.
> 
> file.remove(file.path(ss, list.files(ss)))
> [1] FALSE
> Warning messages:
> 1: In file.remove(file.path(ss, list.files(ss))) :
>  cannot remove file '..... my folder path...', reason 'Read-only file system'
> 
> Also when I tried to delete a single Locked file, I am getting following error:
> 
> Warning message:
> In file.remove(ss1) :
>  cannot remove file '/..... my folder path...', reason 'Operation not
> permitted'
> 
> I am using Mac with OS : 10.7.5
> 
> Could you please help me with correct R code?
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.