{"id":21029595,"url":"https://github.com/aiboy996/windowshardlink","last_synced_at":"2025-12-30T00:07:23.539Z","repository":{"id":170366161,"uuid":"561243076","full_name":"AIboy996/WindowsHardLink","owner":"AIboy996","description":"Windows系统右键小工具，为一个文件夹内的所有文件递归创建Hardlink","archived":false,"fork":false,"pushed_at":"2022-11-03T12:35:27.000Z","size":434,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T15:17:34.862Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AIboy996.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-03T09:14:22.000Z","updated_at":"2024-03-15T12:27:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"6dc1dfba-373b-4272-aae6-0f53c1385e24","html_url":"https://github.com/AIboy996/WindowsHardLink","commit_stats":null,"previous_names":["aiboy996/windowshardlink"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2FWindowsHardLink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2FWindowsHardLink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2FWindowsHardLink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AIboy996%2FWindowsHardLink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AIboy996","download_url":"https://codeload.github.com/AIboy996/WindowsHardLink/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243466986,"owners_count":20295310,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T12:13:19.431Z","updated_at":"2025-12-30T00:07:23.476Z","avatar_url":"https://github.com/AIboy996.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Windows Hard Link\n\n在Windows系统中为文件夹创建hardlink\n\n## 功能演示\n\n![](./assets/动画.gif)\n\n## 安装方法\n\n### 默认方法\n\n- 把根目录的`hl.py`文件放在**桌面**，*以后如果要用这个功能就需要一直放在桌面！*\n- 运行`windows_hardlink.reg`添加注册表信息\n\n### 自定义脚本文件位置\n\n- 修改`windows_hardlink.reg`中脚本文件的位置为`hl.py`所在的位置\n- ![image-20221103184731943](assets/image-20221103184731943.png)\n- 运行`windows_hardlink.reg`添加注册表信息\n\n### 卸载\n\n把之前添加的注册表信息删除即可\n\n![image-20221103184856041](assets/image-20221103184856041.png)\n\n## 原理解释\n\n### 是什么？\n\n- `hardlink（硬链接）`是一个操作系统层面的文件指针，在用户眼中和普通的文件无异（因为所有的文件本质上就是指向数据的一个指针）。通常区别于`symbollink（软链接）`。特别地，在Windwos下还区别于`shortcut（快捷方式）`和 `junction（目录联接）`\n- 使用`CMD`的`mklink`命令可以创建这几类链接（快捷方式较为特殊，有另外的创建方法，这里不赘述）\n```cmd\n\u003e mklink\n创建符号链接。\n\nMKLINK [[/D] | [/H] | [/J]] Link Target\n\n        /D      创建目录符号链接。默认为文件\n                符号链接。\n        /H      创建硬链接而非符号链接。\n        /J      创建目录联接。\n        Link    指定新的符号链接名称。\n        Target  指定新链接引用的路径\n                (相对或绝对)。\n```\n- 硬链接的特性：\n  - **硬链接只能用于单个文件，不能用于文件夹**\n  - 硬链接本身不占用额外的空间。\n  - 如果你修改了硬链接文件的内容，那么源文件也会被修改。\n  - 如果你删除了源文件或者硬链接，另外一份依然保留，不受影响。\n- 下面的图应该能帮助你更好的理解硬链接\n![sasd](./assets/hardlink_and_symbollink.png)\n\n### 为什么？\n- 我在Windows上搭建**Plex媒体库**的时候，经常由于文件名不规范而导致刮削失败。\n- 但同时，由于需要做种，不方便修改源文件的名称。\n- 所以需要硬链接，来达成既可以随意修改文件名称，又不占用额外空间，又能不改变源文件的目标！\n\n### 怎么办？\n#### 递归创建hardlink\n由于硬链接不支持文件夹，想要实现整个文件夹的\"harklink\"那只能递归实现（我打算用python脚本），也就是保持源文件夹的目录结构，对每个文件创建硬链接，从而曲线救国。\n\n根目录的脚本文件运行示例：\n\n```cmd\n\u003e python hl.py example output\n('运行的脚本', 'hl.py')\n('源目录', 'example')\n('目标目录', 'output')\n为 output\\130218(final).pdf \u003c\u003c===\u003e\u003e example\\130218(final).pdf 创建了硬链接\n为 output\\script\\readme.txt \u003c\u003c===\u003e\u003e example\\script\\readme.txt 创建了硬链接\n为 output\\script\\Python\\hello.py \u003c\u003c===\u003e\u003e example\\script\\Python\\hello.py 创建了硬链接\n为 output\\script\\R\\hello.r \u003c\u003c===\u003e\u003e example\\script\\R\\hello.r 创建了硬链接\n为 output\\txt\\a \u003c\u003c===\u003e\u003e example\\txt\\a 创建了硬链接\n为 output\\txt\\hello.txt \u003c\u003c===\u003e\u003e example\\txt\\hello.txt 创建了硬链接\n```\n\n#### 添加到注册表\n并且如果每次都写一个脚本，打开命令行来运行，实在是有些麻烦。我想到用**Windows的右键菜单**来实现一键操作：\n\n（下图点击`创建mkhardlink`即可创建！）\n\n![image-20221103184357962](assets/image-20221103184357962.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiboy996%2Fwindowshardlink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faiboy996%2Fwindowshardlink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faiboy996%2Fwindowshardlink/lists"}