Tool for finding and hardlinking identical files.
Project description
mklinks: tool for finding and hardlinking identical files
Latest release 20250530: Big refactor to use cs.hashindex for the content checks and better internal data structures.
Mklinks walks supplied paths looking for files with the same content, based on a cryptographic checksum of their content. It hardlinks all such files found, keeping the oldest version.
Unlike some rather naive tools out there, mklinks only compares files with other files of the same size, and is hardlink aware; a partially hardlinked tree is processed efficiently and correctly.
Short summary:
Inode: Information about a particular inode.Linker: The class which links files with identical content.main: CLI formklinks.MKLinksCommand: Hard link files with identical contents.
Module contents:
Inode.assimilate(self, other: 'Inode', *, dry_run=False, runstate: Optional[cs.resources.RunState] = <function uses_runstate.<locals>.<lambda> at 0x10b75c220>):
Link our primary path to all the paths from other. Return success.
Inode.from_str(fspath: str, *, hashname: str):
Promote a filesystem path to an Inode.
Inode.key:
A (ino,dev) 2-tuple.
Inode.same_dev(self, other):
Test whether two Inodes are on the same filesystem.
Inode.same_file(self, other):
Test whether two Inodes refer to the same file.
Inode.samefs(self, other):
Test whether 2 Inode's are on the same filesystem (same .dev values).
Inode.stat_key(fspath: str):
Compute the (ino,dev) 2-tuple from os.stat(fspath).
Linker.addpath(self, path):
Add a new path to the data structures.
Linker.merge(self, *, dry_run=False, runstate: Optional[cs.resources.RunState] = <function uses_runstate.<locals>.<lambda> at 0x10b75cd60>):
Merge files with equivalent content.
Linker.scan(self, path, *, runstate: Optional[cs.resources.RunState] = <function uses_runstate.<locals>.<lambda> at 0x10b75c900>):
Scan the file tree.
-
ClassMKLinksCommand(cs.cmdutils.BaseCommand)``: Hard link files with identical contents.Usage summary:
Usage: mklinks [common-options...] subcommand [options...] Hard link files with identical contents.
MKLinksCommand.Options
MKLinksCommand.main(self, argv):
Usage: {cmd} paths...
Hard link files with identical contents.
Release Log
Release 20250530: Big refactor to use cs.hashindex for the content checks and better internal data structures.
Release 20221228:
- Modernise command, pass a RunState to the merge methods.
- merge: check runstate more frequently, tweak progress bar.
- assimilate: plumb runstate.
Release 20210404:
- FileInfo.checksum: bump read size to 1MiB.
- Requirements bump to match cs.cmdutils change.
Release 20210401: Major bugfix: subdirectory file paths were computed incorrectly.
Release 20210306: Use cs.cmdutils.BaseCommand for main programme, add better progress reporting.
Release 20171228: Initial PyPI release of cs.app.mklinks.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cs_app_mklinks-20250530.tar.gz.
File metadata
- Download URL: cs_app_mklinks-20250530.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7ff542857d0c8213ea6872bbf429ea8d7f5809a6249929d78ba29d5f1b08f29
|
|
| MD5 |
0d86118f4fc0c29fb6f350963f6b4c82
|
|
| BLAKE2b-256 |
7b8f3a6f59e45f7550fef137aec1dab3ccd8ca5bdd9be61f12fecec00a89bb8f
|
File details
Details for the file cs_app_mklinks-20250530-py2.py3-none-any.whl.
File metadata
- Download URL: cs_app_mklinks-20250530-py2.py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0c6543e986a7360123be0464aab133834a4002483da238998c485c0ff5de4d5
|
|
| MD5 |
7979f8c9ca2fcf028af125bac266102d
|
|
| BLAKE2b-256 |
d3a7a6ea5a1e61e47cf046187e0be2455b6693715b6f903d82f22340be41f1cb
|