When you accidentally deleted files on your iMac, the files are not gone forever. It just marks the space the deleted files used to occupy can be used for new data. That is to say, you can recover files from the deleted files with data recovery software as long as the data haven't been overwritten.
There are many data recovery software in the market, here I advise iBoysoft Data Recovery for Mac. iBoysoft Data Recovery for Mac is one of the best data recovery software in the market. It is professional, 100% secure, reliable, and easy to use.
This professional data recovery software can easily recover deleted files from Mac hard drives, SD cards, external drives, USB drives, etc. This powerful data recovery tool is compatible with Intel Macs and Apple Silicon Macs with M1 and M2 chips and also works on macOS 13/12/11/10.15/10.14/10.13/10.12 and OS X 10.11. Moreover, it can recover emptied Mac Trash.
To recover deleted files from your iMac, do the following:
Step 1. Download and install iBoysoft Data Recovery for Mac.
Step 2. Launch the recovery software from Mac Finder or Mac Launchpad.
Step 3. Select the Mac hard drive under Data Recovery from the left sidebar.
Step 4. Click the Search for Lost Data at the right bottom to start scanning.
Step 5. Filter files by different categories and then preview recoverable files.
Step 6. Select all the desired deleted files and click the Recover button to save them to a different location.
If your iMac is running older macOS OS X 10.10 and earlier, you may need to update your Mac to a macOS version that can be compatible with the iBoysoft Data Recovery software and then perform data recovery. If you're worried about updating macOS will cause data loss, you can try an open-source data recovery software -TestDisk, which should be available on older macOS.