Manual:FindOrphanedFiles.php

Details
findOrphanedFiles.php maintenance script finds unregistered files in the 'public' repo zone.

MediaWiki uses image/ directory for their public images. It shows all those images' path which exists in this public directory but does not register in the database.

Options
findOrphanedFiles.php accepts only two options.

Common error
This script does not work when your local storage use SHA-1 hashing.
 * Local repo uses SHA-1 file storage names; aborting.

It comes when the directory does not exist or the user running the script does not have permission to read the directory.
 * Could not get file listing.

In case directory does exist, check file permission. If you are root user then you can run script with sudo.