I have an old Western Digital External Hard Drive (lets call it “Drive#1”) It is an old WD Drive that is a local drive (Not a Network/NAS), meaning it only works when it is hardwired connected to my Mac.
I’ve been copying a bunch of files from this “Drive #1” HD to a Networked/NAS External HD (Lets call this “NAS #2”) so that others in my household can access those files on the “NAS#2” if needed.
Now that I have copied these files to “NAS#2”, I now want to delete the files from the original “Drive#1”. However, I am getting the following error when I try to delete the files:
The operation can’t be completed because some items had to be skipped. For each item, choose File > Get Info, make sure “Locked” is deselected, and then check the Sharing & Permissions section. When you are sure the items are unlocked and not designated as Read Only or No Access, try again.
There are a lot of individual files in these folders that I have moved, so hunting through all of them for the individual files that may be “Locked” and blocking me is prohibitive. Any suggestions as to what I need to do here? I’ve tried rebooting the drive and disconnecting and reconnecting the “Drive#1” with no luck.
I’d rather not wipe the drive as there are other files on the “Drive#1” that I don’t feel like blowing away and having to re-establish them on the drive.
If this drive is “just a bunch of files” I would start by opening Get Info for the drive and applying the existing permissions for the drive to all the files by choosing “Apply to enclosed items.”
It’s unlikely this would cause you any problems but it wouldn’t hurt to wait for a “second opinion” from another MPU.
Locking is implemented using an old mechanism called “flags”, which is implemented separately from file permissions and extended attributes. The terminal commands “ls” and “find” are both flags-aware. If I have some files, one of which is locked, then:
$ ls -l *.txt
-rw-r–r-- 1 Jim staff 0 Mar 23 19:32 bar.txt
-rw-r–r-- 1 Jim staff 0 Mar 23 19:32 baz.txt
-rw-r–r-- 1 Jim staff 0 Mar 23 19:32 foo.txt
$ ls -lO *.txt
-rw-r–r-- 1 Jim staff - 0 Mar 23 19:32 bar.txt
-rw-r–r-- 1 Jim staff - 0 Mar 23 19:32 baz.txt
-rw-r–r-- 1 Jim staff uchg 0 Mar 23 19:32 foo.txt ← This is the locked file!
$ find . -flags uchg
./foo.txt
Knowing this you can find the files that are locked and unlock them one by one. There are also terminal commands to clear the flags, if you’re interested.
If you are coping towards a NAS, could I assume, that the space there extends the size of all Files on Drive#1?
If yes, I would simply copy everything from there towards the NAS, erase Drive#1, and copy those files you want to keep there back to the Drive.
Connect your drive as usual, then fire up Terminal. Then do this:
find /Volumes/Drive1 -flags uchg
Substitute the real name of the drive for “Drive1”. If there are space characters in the name, put a backslash before each space character, e.g. Drive\ 1 .
That should list the locked files. There may be other files with permission issues, we can deal with them later.
I have a sizable set of files/documents on “Drive#1” that I intend to leave on that drive.
I have a sizable set of files that I have just copied from “Drive#1” to “NAS#2”. It is this set of files that are causing me the issues I have outlined (not letting me delete the files from “Drive#1”).
As noted by @jec0047 , I’d really rather not wipe “Drive#1” unless I am completely out of options. Ergo, that is why I came here - to see if folks who are much more knowledgeable about these things could help me figure out how to remove said files from “Drive#1” before I have to contemplate wiping the drive.
I do understand that, but in a lot of cases, these operations via Terminal are taking a lot of time, specially if you are working seldom with the terminal.
So the Copy-Erase-Copy Thing could be way more time saving, if you have enough space available, as it does the majority of the work without the need of your permanent attention and input, for Example during the night, and it could be “healthy” for a drive to Erase it from time to time, as DiskUtility is also able to isolate faulty parts of the drive during this.
That is why I suggested this way.
Of course, it also depends on the numbers of files you have to deal with…
The good news is that the method @WayneG suggested
find /Volumes/Drive1 -flags uchg
worked and I was able to find the ‘needles’ in the data haystack that was throwing that previous error. So thank you (!!) for the tip!!
I have been able to now delete ~97% of the files on “Drive#1” that I had copied over to “NAS#2”. Unfortunately, it is that last ~3% that are now causing me heartburn. They are a random set of lingering files/images are throwing me the following error, which is just baffling me
The operation can’t be completed because the item [FILE_NAME] is in use.
And I can’t figure out what is using these random photos/images/files on this external hard drive. The drive is old and I’m not seeing anything on the WD site like an app to help me manage the drive. Will continue to look for that. I’m wondering if these files may be corrupted in some way. Is there a method in Terminal that would enable me to target and delete these specific files that Finder is not letting me?
You can try the “Delete Immediately …” option by holding down the Control key and clicking on the file in the trash. This will bring up a contextual menu:
Where “yourDriveName” is the name of the drive you’re having the issue with. This should list the files in use.
“lsof” is the command to list open files. “grep” is the command to find patterns. The “|” is a pipe that takes the output of the lsof command and feeds it to the grep command, which will subset it to files on the problematic drive. The first column of the output is what (the system thinks) is using the file.
I had problems with a drive that I could not eject because files were in use, and found this, but I do not remember where or from who. Perhaps someone else can chime in with more info.
Yeah, that is one of the reasons, I recommended an other way.
There could be a ton of reasons for this error, and you have to go true them to figure out what might be the reason on your device.
If you run a Google Search with the error in it, you will get a lot of pages with different solutions to solve the different reasons for the error.
Just to close this out - I rebooted/reset both drives and the “files not deleting” issues resolved. So all good and was able to finish out the file migration and deletions. Thanks for all the help!!