Since you’re sharing an entire directory — and not just a single file — sha512sum and stat won’t work directly on a folder because they’re designed for files. But there are definitely good ways to verify the whole directory’s integrity. Let’s go over a couple of them:


Option 1: Generate a Hash of All Files in the Directory
You can create a list of hashes for every file inside the directory and compare them on both ends.

On your side (before sending):

find <directory> -type f -exec sha512sum {} + | sort > directory-checksum.sha512
  • find <directory> lists all the files.
  • -type f ensures only files are hashed, skipping directories.
  • sha512sum {} generates a hash for each file.
  • sort ensures the order of files doesn’t affect the results.
  • > directory-checksum.sha512 saves the hashes to a file.

After your friend downloads and extracts the directory, they run:

find <directory> -type f -exec sha512sum {} + | sort > downloaded-checksum.sha512

Then compare:

diff directory-checksum.sha512 downloaded-checksum.sha512

If there’s no output, the directories match perfectly.


Option 2: Create a Tar Archive and Hash It
Another approach is to archive the directory and hash the archive itself.

On your side:

tar -cvf directory.tar <directory>
sha512sum directory.tar

Your friend does the same after downloading and extracting:

sha512sum directory.tar

If the hashes match, the directory is identical.


Option 3: Compare File Sizes and Checksums Together
For an extra layer of safety, you can also capture file sizes along with hashes:

find <directory> -type f -exec stat --format="%s %n" {} + | sort > directory-file-sizes.txt
diff directory-file-sizes.txt downloaded-file-sizes.txt

Option 4: rsync with Checks
If you and your friend have SSH access to the target machine, rsync can verify files as it transfers them.

rsync -avz --checksum <directory> user@remote:/path/to/destination/

The --checksum flag ensures rsync checks file integrity with hashes, not just file size and modification time.