Skip to main content

Compare folder contents via hash. File I/O and hashing are done in threads using the Curio library to make the comparison as speedy as possible!

I use folderhash for extra assurance that large or important file copies have been performed accurately.

Installation

Installation from PyPI should be easy:

$ pip install folderhash

folderhash supports only Python 3.6 or later.

Demo

$ mkdir -p /tmp/demo/a /tmp/demo/b  # just some setup
$ cd /tmp/demo
$ touch a/a a/b a/c b/a b/b b/d
$ echo "DIFFERENT CONTENT" >> a/b

$ folderhash a b  # the simplest case--compare two folders
9fb5d41e2533b73381bdde8e3ac2d60a6a18467674771187595d83e9bfa30909 a/b
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a b/b

a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a a/c
ABSENT b/c

ABSENT a/d
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a b/d

$ # you can change the hash algorithm!
$ # all of the algorithms in your Python's `hashlib` are available
$ # default is sha3_256
$ folderhash -s md5 a b
128edd12d0b04e23d10c4747d0da2c03 a/b
d41d8cd98f00b204e9800998ecf8427e b/b

d41d8cd98f00b204e9800998ecf8427e a/c
ABSENT b/c

ABSENT a/d
d41d8cd98f00b204e9800998ecf8427e b/d

$ # it works with relative paths, too
$ cd a
$ folderhash . ../b
9fb5d41e2533b73381bdde8e3ac2d60a6a18467674771187595d83e9bfa30909 ./b
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a ../b/b

a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a ./c
ABSENT ../b/c

ABSENT ./d
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a ../b/d

$ # you can do the hashing separately and compare at a later time
$ # absolute paths are always shown here
$ cd ..
$ folderhash a > a.txt
$ folderhash b > b.txt
$ folderhash -a a.txt -b b.txt
9fb5d41e2533b73381bdde8e3ac2d60a6a18467674771187595d83e9bfa30909 /tmp/demo/a/b
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a /tmp/demo/b/b

a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a /tmp/demo/a/c
ABSENT /tmp/demo/b/c

ABSENT /tmp/demo/a/d
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a /tmp/demo/b/d

$ # the format of the hash files is simple: {hash_value}<SP>{full_path}
$ cat a.txt
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a /tmp/demo/a/a
9fb5d41e2533b73381bdde8e3ac2d60a6a18467674771187595d83e9bfa30909 /tmp/demo/a/b
a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a /tmp/demo/a/c

Changelog

Changes as of 8 August 2017

1.0.1 <8 August 2017>

  • Some readme fixes

  • Change the PyPI development status classifier from Beta to Production/Stable

  • Show paths relative to the input argument instead of absolute paths when producing output. I think it’s easier to understand this way.

  • Add some error checking for input of empty hash files

1.0.0 <7 August 2017>

  • Initial stable release to PyPI!

Contributing

There are many ways to contribute to an open-source project, but the two most common are reporting bugs and contributing code.

If you have a bug or issue to report, please visit the issues page on Github and open an issue there.

License

MIT. See the LICENSE.rst file for more information.

Release files for folderhash 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for folderhash 1.0.1
File Size Uploaded
folderhash-1.0.1.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for folderhash 1.0.1
File Interpreter ABI Platform
folderhash-1.0.1-py36-none-any.whl Python 3.6 none any Details

Total release size: 16.8 kB

Release files / folderhash-1.0.1.tar.gz

Download URL folderhash-1.0.1.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2192716be457828e348a06441276d132b75a279ab00320b27cd9421bf824dfd4
BLAKE2b-256 checksum
How to use checksums
16b4176bf6bcc3f69c7dea644694428daed6a97351d2356de9cd07128b93f981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / folderhash-1.0.1-py36-none-any.whl

Download URL folderhash-1.0.1-py36-none-any.whl
Size 9.0 kB
Tags Python 3.6
SHA-256 checksum
How to use checksums
d4eba02d713acd238a79c83860e173db837472017623ac509737056e21d9c2b1
BLAKE2b-256 checksum
How to use checksums
652daab960c1ae83df0c47bb4fcebe202a1f50d6a991c7bfdbb0f5fda9cc88d6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page