Delete a folder with a lot of files I'm not even sure how to ask this question properly, but let me try.

I'm on Mojave 10.14.

I found a directory in my trash can that is extremely slow to delete. When I try to go into the directory, finder shows spinning at the bottom and does not displays the files in it. I've waited well over 10 mins.

When I try to use "ls" cmd in the terminal, it also takes over 10 mins and does not display anything.

When I try to empty the trash, it is EXTREMLY slow. The # of files deleted increases 1 per second (almost). I've waited well over 30 mins and it was still not finished.

How do I diagnose this problem and find a solution?

Update 1: Filesystem is APFS and the directory has more than  12,000,000 small json files.
Update 2: Finally counted the # of files and total size of the directory. The directory has 22,203,359 files and 27.59GB.
When I try to use "ls" cmd in the terminal, it also takes over 10 mins and does not display anything.


This is not normal.  Something is amiss. I'd see the most likely cause as either a bad filesystem or a failing drive. While surprising, it could be a bad spot on the drive just where the directory is.  In the case of a failing drive, macOS will try multiple reads to see if it can retrieve the data. 

/Applications/Utilities/Disk Utility


goto the First Aid tab.  Should you find problems, you will have to boot in the recovery manager. command + r at boot time before the beep.  click on the utilities tab and select disk utility.

High Sierra's Disk Utility



Yosemite's Disk Utility




Try a safe boot.  It's always a good idea to try safe mode when strange things happen. 

Shutdown your machine.  Hold down the shift key.  Poweron.  The boot up will take longer than normal because the filesystem on the startup drive is being checked and repaired as needed.   All about safe mode including what features and apps safe boot leaves out.  Safe boot uses a software driver instead of using your machines video hardware.
  http://support.apple.com/kb/ht1455