Trouble deleting 160,000 files on Western Digital MyBook fileserver

I can’t complete the task of deleting all the files in one folder of my network fileserver, a Western Digital MyBook. I can select all the files in Mac’s Finder (which is like Windows Explorer) and command it to delete them, and it busies itself for many hours, and then stops responding. It does make some progress, deleting perhaps 2% of the files, but then it stops updating the progress indicator, and refreshing the Finder display does nothing, and I can’t browse into the drive’s configuration page. It takes a few minutes of playing with the power/reset button on the drive itself to turn it off, and I can feel it seeking constantly.

It does always come back, and I can navigate to and open files in the folder, but I’m looking at more hours of work than the product is actually worth to go through this 50 times to clear the folder.

The files are small automatically generated .jpg files from several network security cameras.

Any advice? Thanks!

Open a terminal window and delete them from the command line.

You need to work out the path name of the directory. This will be relative to the mount point of the drive. You should be able to see it in /Volumes.

Use the “cd” command to change directory to the directory full of the files. Then use the “rm” command to remove the files. Probably with “rm *.jpg” If you want to kill everything in a directory you can use “rm -rf directory-name” This will remove the directory and its contents. This will still take a while with so many files.

If you have never used a Unix command line this isn’t going to be enough information to feel really confident, but you can probably find any number of introductory guides to using the commands, and knowing where to start it should be hard to do. But be careful, and double check what you do. There is no recovery from use of “rm”. There is no undelete mechanism, not even with disk recovery tools if you get the command wrong.

Thanks. I mostly used Unix until about 15 years ago and feel comfortable enough trying it that way with references at hand, though if there was something that allowed the normal tool to do it, I would have preferred it. I have a fairly new command guide here someplace…

I second this approach. When you use the Finder to delete files, it moves them to the trash, which is a folder on the same device. That might cause thrashing, and you still need to empty the trash. Unix rm bypasses this.

You can easily get the path in the terminal window by dragging a folder and dropping it in the terminal window.

Are those files all in the same folder? That’s a bit beyond the norm.

You might want to investigate the different filesystems available and switch to the one that best can handle so many files.

OK, how do I find the mount point of this network drive?

If I open a terminal window and su and cd / and then ls, I see Volumes as well as a few other things, but inside Volumes there appears to be a single item named “Macintosh HD”. I hunted around elsewhere but didn’t see anything with its host name.

If I drag the folder from the Finder window to the Terminal window, I don’t see anything happening - how is this supposed to get the path in the terminal window?

I didn’t mean to accumulate this many files, but I figure it’s going to happen from time to time. They’ll all be the same kind of file, all fairly small, and there won’t be anything else in that folder. I will want to be able to Preview them, and copy them. There will be other folders on this drive, too. What different filesystem can do this job better, bearing in mind that this was a tidy little packaged network drive? I might have noticed somewhere that it was running Ubuntu, but this is a vague recollection.

Thanks!!

Well, crap, now I can’t access it in any way, either as a disk drive or through a configuration page. I can ping it, but I haven’t found anything else it can do.

I just verified that in Snow Leopard I can open a Finder window, open a Terminal window, and then drag a folder from Finder and drop it in the center of the Terminal window. The absolute path to the dropped folder appears in the terminal window, as if I had typed it in from the keyboard.

And it’s a bit of a mystery why the share doesn’t show up in /Volumes. Is the drive mounted?

As far as different filesystems go, I can’t say which one is best for huge numbers of files like that—that’s where a bit of research is in order. Nevertheless, some filesystems are optimized for different things.

For example, if I were to make a small Ubuntu media server (like a Squeezebox server), I would probably use ext2 instead of the more common ext3, simply because ext2 is not a journaling filesystem and it handles updates much faster. Of course this assumes that the server does not have the only copy of the media files.

I think I’m doing what you describe: from a Finder window, I drag a folder into the main pane of a Terminal window. Nothing. The little folder graphic with the mouse cursor seems to shoot back towards the Finder window as I let it go and before it vanishes, in what I understand is a gesture indicating the drag target was inappropriate. This, too, is Snow Leopard.

As to whether the share is mounted, not perfectly clear what you mean. It shows up in the SHARED pane at left in Finder, but I didn’t use the UNIX “mount” command to put it there. I think that if it appears there and I can use it, it’s mounted, right?

It also sounds as though I should see it in Disk Utility, but the only things there are my Mac HD and the Mac DVD drive. We have another fileserver, too, and it seems to act the same way.

I started being able to communicate with the drive again. Don’t know why. But I am trying a new tactic. I deleted the entire folder that contains the files. 8 minutes ago there were 120,444 files to go. Now there are 120362 files to go, which is 60 files in 8 minutes. It seems to take 8 seconds to delete each file, in other words. Or, about 10 days to delete them all.

This drive has some goofy automatic backup program called SmartWare that tries to take over the computer using it, which I think I managed to avoid, but I am not sure. I was reading posts in the Western Digital Community, which is the organization people join to learn how not to use SmartWare, and which for some reason is sponsored by Western Digital. Maybe it is community service. Anyway, I don’t remember how I avoided it, and I guess I’m not sure I did. There seem to be two related shared drives in Finder: Napierdrive and Napierdrive-Backup; but Napierdrive-Backup doesn’t work when I try to open it.

I also don’t know what Trash is doing here. Nothing appears in Trash unless I delete it from my local hard drive, unless there are other Trashes that I don’t know how to look in.

I don’t think SMB shares will show up in Volumes. Which means you won’t be able to delete from the command line.

Can you plug the drive in via USB?

The drive can’t be plugged in by USB.

It deleted files all night but at the rate of only about 2 files per minute. There are still 115,682 files. In the last few minutes several more were deleted. I can still access and write and delete files, but the deletion is fantastically slow. The drive still reports 960 GB of free space.

I updated the firmware, which was the original August '09 version. This appeared to work without any problem. Now I can connect to its config page, and all the network and user and share settings still look correct, but trying to open it as a disk drive has taken several minutes so far with nothing showing yet.

At this point it has cost much more to mess with it than it did to purchase it, but it would also cost time and money to find an alternative and learn all its quirks. Hard to know what to do.

My SMB network shares show up in Volumes.

Of course, there may have been some weird secret Mac thing I did years ago when I set them up.
Networking (especially CIFS/SMB) is a weak area for OS X IMHO.

ETA: I wasn’t even thinking about the network side of things. Of course the deletes are going to be slow. It’s a network drive!
I imagine that if you have everything in one huge folder, Finder is still trying to get metadata for a zillion files, one by one, in order to render their icons. Meanwhile you are trying to delete them.

A fast network (gigabit all the way) and using the command line should sort this out. A bit of tweaking in the network preferences pane might get the share to appear in Volumes.

As a bare minimum, you might try changing the Finder view to not show thumbnails.

It is starting to sound as if you need to do the inverse function.

Copy everything else off the drive and reformat it.

Network file servers are notoriously bad at file operations, there is typically a huge amount of synchronous futzing about for almost any operation. Actual IO rates are often not bad, but the rest can be very bad. Huge numbers of files in one place can bring many things to their knees. Somewhere there is one poor little directory will all the meta-data in it. Often he manner in which this data is managed is not very efficient.

There is a hack to allow ssh access into the WD Mybook here. YMMV, no warranty offered.

This will allow you to log on directly to the Mybook linux shell, and then you can use rm locally to delete the files. This will be far more successful than trying to do this over samba. The combination of how the Finder handles deletion and the limitations of the server itself means that things will often fail.

Si

This will sound dumb, but, I don’t know how to format it. It does not appear in Disk Utility, and I have not found formatting means in its web configuration page.

The input and output of files is pretty quick. These files are .jpg pictures, and I can preview them in Finder while holding down the up or down arrows, and get a somewhat jerky but plausible rendition of moving pictures. But deleting them is only proceeding at about two per minute.

In other words, I can view the files as images about 100x faster than I can delete them by multiple selection.

The hack above looks great. All it does is enable ssh login - it is a one character change to the internal config of the server. Then you can do all you need easily. Same as before with a unix shell, but this time on the actual server box.

In Windows you can Shift-Delete to permanently delete the files, with no trash/recycle involved. Is there something similar in OSX?

The SSH hack would be the ideal way to access and handle that pesky directory.
If you are unable or hesitant to do that though, try going to your shell and run the mount utility with no switches. That will show you where your mount points are and their actual mount point names.
From there, it’s a cd to that mount point and above the troublesome directory, then an rm -rf that troublesome directory. It WILL take some time, but not that 8 minutes per.
Samba is troublesome for large file operations, large number of file operations and such. It, like windows smb, is extremely chatty. But, you’d bypass the trash issue, the time estimating nonsense and a bunch of other stuff that finder or windows explorer likes to do.
Whenever possible and practical, I stuck with the command line, when administering ANY file server. It saved time and made large batch changes MUCH easier and efficient.