file-org-kit 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BoiledSaltedDuck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: file-org-kit
3
+ Version: 1.0.0
4
+ Summary: 文件智能分类整理工具 - 按类型或日期自动归档文件,告别杂乱下载目录
5
+ Author-email: BoiledSaltedDuck <tools@office-tools.pro>
6
+ License: MIT
7
+ Keywords: file,organize,organizer,分类,整理,归档
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: System :: Filesystems
12
+ Classifier: Topic :: Utilities
13
+ Requires-Python: >=3.7
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # file-org-kit 文件智能分类整理工具
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/file-org-kit)](https://pypi.org/project/file-org-kit/)
21
+ [![Downloads](https://img.shields.io/pypi/dm/file-org-kit)](https://pypi.org/project/file-org-kit/)
22
+ [![License](https://img.shields.io/pypi/l/file-org-kit)](https://github.com/BoiledSaltedDuck/file-org-kit/blob/main/LICENSE)
23
+
24
+ ## 安装
25
+
26
+ ```bash
27
+ pip install file-org-kit
28
+ ```
29
+
30
+ ## 用法
31
+
32
+ ```bash
33
+ # 按文件类型分类
34
+ file-org ./下载/ type ./整理后/
35
+
36
+ # 按修改日期分类
37
+ file-org ./桌面/ date
38
+ ```
39
+
40
+ ## 按类型分类 (type)
41
+
42
+ 自动识别以下文件类型并分类到对应目录:
43
+
44
+ | 类别 | 支持的扩展名 |
45
+ |------|------------|
46
+ | 图片 | jpg, png, gif, webp, svg, bmp, tiff... |
47
+ | 文档 | pdf, doc, xls, ppt, txt, md, csv... |
48
+ | 压缩包 | zip, rar, 7z, tar, gz, bz2... |
49
+ | 视频 | mp4, avi, mkv, mov, flv... |
50
+ | 音频 | mp3, wav, flac, aac, ogg... |
51
+ | 代码 | py, js, java, go, rs, cpp, rb... |
52
+ | 网页 | html, css, scss... |
53
+ | 配置 | json, xml, yaml, toml, ini... |
54
+ | 可执行 | exe, msi, apk, deb, rpm... |
55
+ | 字体 | ttf, otf, woff... |
56
+
57
+ ## 按日期分类 (date)
58
+
59
+ 按文件的最后修改时间,自动以 `年-月` 格式分目录归档。
60
+
61
+ ## 特点
62
+
63
+ - 零配置,安装即用
64
+ - 自动处理重名文件(添加编号后缀)
65
+ - 安全移动,非复制
66
+ - 纯 Python,零依赖
67
+
68
+ ## 支持
69
+
70
+ 如果 file-org-kit 帮到了您,欢迎打赏支持:
71
+
72
+ ```
73
+ USDT (TRC20): TMPQygMkv42QPeyYnkxMkPwsqs7udbD2Aa
74
+ ```
75
+
76
+ 您的支持是开源项目持续发展的动力 ❤️
@@ -0,0 +1,59 @@
1
+ # file-org-kit 文件智能分类整理工具
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/file-org-kit)](https://pypi.org/project/file-org-kit/)
4
+ [![Downloads](https://img.shields.io/pypi/dm/file-org-kit)](https://pypi.org/project/file-org-kit/)
5
+ [![License](https://img.shields.io/pypi/l/file-org-kit)](https://github.com/BoiledSaltedDuck/file-org-kit/blob/main/LICENSE)
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ pip install file-org-kit
11
+ ```
12
+
13
+ ## 用法
14
+
15
+ ```bash
16
+ # 按文件类型分类
17
+ file-org ./下载/ type ./整理后/
18
+
19
+ # 按修改日期分类
20
+ file-org ./桌面/ date
21
+ ```
22
+
23
+ ## 按类型分类 (type)
24
+
25
+ 自动识别以下文件类型并分类到对应目录:
26
+
27
+ | 类别 | 支持的扩展名 |
28
+ |------|------------|
29
+ | 图片 | jpg, png, gif, webp, svg, bmp, tiff... |
30
+ | 文档 | pdf, doc, xls, ppt, txt, md, csv... |
31
+ | 压缩包 | zip, rar, 7z, tar, gz, bz2... |
32
+ | 视频 | mp4, avi, mkv, mov, flv... |
33
+ | 音频 | mp3, wav, flac, aac, ogg... |
34
+ | 代码 | py, js, java, go, rs, cpp, rb... |
35
+ | 网页 | html, css, scss... |
36
+ | 配置 | json, xml, yaml, toml, ini... |
37
+ | 可执行 | exe, msi, apk, deb, rpm... |
38
+ | 字体 | ttf, otf, woff... |
39
+
40
+ ## 按日期分类 (date)
41
+
42
+ 按文件的最后修改时间,自动以 `年-月` 格式分目录归档。
43
+
44
+ ## 特点
45
+
46
+ - 零配置,安装即用
47
+ - 自动处理重名文件(添加编号后缀)
48
+ - 安全移动,非复制
49
+ - 纯 Python,零依赖
50
+
51
+ ## 支持
52
+
53
+ 如果 file-org-kit 帮到了您,欢迎打赏支持:
54
+
55
+ ```
56
+ USDT (TRC20): TMPQygMkv42QPeyYnkxMkPwsqs7udbD2Aa
57
+ ```
58
+
59
+ 您的支持是开源项目持续发展的动力 ❤️
@@ -0,0 +1,4 @@
1
+ """file-org-kit - 文件智能分类整理工具"""
2
+
3
+ __version__ = "1.0.0"
4
+ from . import organizer
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ file-org-kit - 文件智能分类整理工具
4
+ 功能:按扩展名/文件类型自动将文件分类到对应目录
5
+ 用法:file-org [输入目录] [模式] [输出目录(可选)]
6
+ file-org ./下载/ type ./整理后/
7
+ file-org ./桌面/ date
8
+ """
9
+ import sys
10
+ import shutil
11
+ from pathlib import Path
12
+ from datetime import datetime
13
+
14
+ # 文件类型分类规则
15
+ FILE_CATEGORIES = {
16
+ "图片": ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg', '.ico', '.tiff', '.tif', '.psd', '.raw'],
17
+ "文档": ['.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.txt', '.md', '.csv', '.odt', '.odp', '.ods'],
18
+ "压缩包": ['.zip', '.rar', '.7z', '.tar', '.gz', '.bz2', '.xz', '.zst', '.iso'],
19
+ "视频": ['.mp4', '.avi', '.mkv', '.mov', '.wmv', '.flv', '.webm', '.m4v', '.mpg', '.mpeg'],
20
+ "音频": ['.mp3', '.wav', '.flac', '.aac', '.ogg', '.wma', '.m4a', '.opus'],
21
+ "代码": ['.py', '.js', '.ts', '.java', '.cpp', '.c', '.h', '.hpp', '.go', '.rs', '.rb', '.php', '.swift', '.kt', '.scala', '.sh', '.bash', '.zsh', '.sql', '.r', '.pl'],
22
+ "网页": ['.html', '.htm', '.css', '.scss', '.less', '.jsx', '.tsx', '.vue', '.svelte'],
23
+ "配置文件": ['.json', '.xml', '.yaml', '.yml', '.toml', '.ini', '.cfg', '.conf', '.env', '.properties'],
24
+ "可执行文件": ['.exe', '.msi', '.appimage', '.deb', '.rpm', '.dmg', '.apk'],
25
+ "字体": ['.ttf', '.otf', '.woff', '.woff2', '.eot'],
26
+ }
27
+
28
+ def _get_category(ext):
29
+ """根据扩展名返回文件类别"""
30
+ ext = ext.lower()
31
+ for category, exts in FILE_CATEGORIES.items():
32
+ if ext in exts:
33
+ return category
34
+ return "其他"
35
+
36
+ def _get_month_dir(date_obj):
37
+ """根据日期返回月份目录名,如 2026-06"""
38
+ return date_obj.strftime("%Y-%m")
39
+
40
+ def org_by_type(input_dir, output_dir):
41
+ """按类型分类"""
42
+ src_path = Path(input_dir)
43
+ dst_path = Path(output_dir)
44
+ return _organize_files(src_path, dst_path, "type")
45
+
46
+ def org_by_date(input_dir, output_dir):
47
+ """按日期分类"""
48
+ src_path = Path(input_dir)
49
+ dst_path = Path(output_dir)
50
+ return _organize_files(src_path, dst_path, "date")
51
+
52
+ def _organize_files(src_path, dst_path, mode):
53
+ if not src_path.exists():
54
+ print(f"错误:目录 {src_path} 不存在")
55
+ return False
56
+
57
+ files = [f for f in src_path.iterdir() if f.is_file()]
58
+ if not files:
59
+ print(f"目录 {src_path} 中没有文件")
60
+ return False
61
+
62
+ print(f"找到 {len(files)} 个文件")
63
+ moved = 0
64
+
65
+ for f in sorted(files):
66
+ try:
67
+ if mode == "type":
68
+ cat = _get_category(f.suffix)
69
+ target_dir = dst_path / cat
70
+ elif mode == "date":
71
+ mtime = datetime.fromtimestamp(f.stat().st_mtime)
72
+ target_dir = dst_path / _get_month_dir(mtime)
73
+ else:
74
+ return False
75
+
76
+ target_dir.mkdir(parents=True, exist_ok=True)
77
+ target_path = target_dir / f.name
78
+
79
+ # 处理重名
80
+ counter = 1
81
+ while target_path.exists():
82
+ stem = f.stem
83
+ target_path = target_dir / f"{stem}_{counter}{f.suffix}"
84
+ counter += 1
85
+
86
+ shutil.move(str(f), str(target_path))
87
+ print(f" ✓ {f.name} → {target_dir.name}/")
88
+ moved += 1
89
+
90
+ except Exception as e:
91
+ print(f" ✗ {f.name} 移动失败: {e}")
92
+
93
+ print(f"\n完成!成功整理 {moved}/{len(files)} 个文件到 {dst_path}")
94
+ _show_promotion()
95
+ return moved > 0
96
+
97
+ def _show_promotion():
98
+ print("\n" + "=" * 55)
99
+ print(" 🔧 file-org-kit - 文件智能分类整理工具")
100
+ print(" 📦 pip install file-org-kit")
101
+ print(" ☕ 如果帮到了您,欢迎打赏支持:")
102
+ print(" USDT(TRC20): TMPQygMkv42QPeyYnkxMkPwsqs7udbD2Aa")
103
+ print(" ⭐ https://github.com/BoiledSaltedDuck/file-org-kit")
104
+ print("=" * 55)
105
+
106
+ def main():
107
+ if len(sys.argv) < 3:
108
+ print("用法: file-org [输入目录] [模式] [输出目录(可选)]")
109
+ print("模式:")
110
+ print(" type - 按文件类型分类(图片、文档、视频等)")
111
+ print(" date - 按修改日期分类(按年月分目录)")
112
+ print("示例: file-org ./下载/ type ./整理后/")
113
+ print(" file-org ./桌面/ date")
114
+ sys.exit(1)
115
+
116
+ input_dir = sys.argv[1]
117
+ mode = sys.argv[2].lower()
118
+
119
+ if mode not in ("type", "date"):
120
+ print(f"错误:不支持的模式 '{mode}',仅支持 type 和 date")
121
+ sys.exit(1)
122
+
123
+ output_dir = sys.argv[3] if len(sys.argv) > 3 else f"{input_dir.rstrip('/')}_整理后"
124
+
125
+ if mode == "type":
126
+ success = org_by_type(input_dir, output_dir)
127
+ else:
128
+ success = org_by_date(input_dir, output_dir)
129
+
130
+ sys.exit(0 if success else 1)
131
+
132
+
133
+ if __name__ == "__main__":
134
+ main()
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.4
2
+ Name: file-org-kit
3
+ Version: 1.0.0
4
+ Summary: 文件智能分类整理工具 - 按类型或日期自动归档文件,告别杂乱下载目录
5
+ Author-email: BoiledSaltedDuck <tools@office-tools.pro>
6
+ License: MIT
7
+ Keywords: file,organize,organizer,分类,整理,归档
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: System :: Filesystems
12
+ Classifier: Topic :: Utilities
13
+ Requires-Python: >=3.7
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # file-org-kit 文件智能分类整理工具
19
+
20
+ [![PyPI version](https://img.shields.io/pypi/v/file-org-kit)](https://pypi.org/project/file-org-kit/)
21
+ [![Downloads](https://img.shields.io/pypi/dm/file-org-kit)](https://pypi.org/project/file-org-kit/)
22
+ [![License](https://img.shields.io/pypi/l/file-org-kit)](https://github.com/BoiledSaltedDuck/file-org-kit/blob/main/LICENSE)
23
+
24
+ ## 安装
25
+
26
+ ```bash
27
+ pip install file-org-kit
28
+ ```
29
+
30
+ ## 用法
31
+
32
+ ```bash
33
+ # 按文件类型分类
34
+ file-org ./下载/ type ./整理后/
35
+
36
+ # 按修改日期分类
37
+ file-org ./桌面/ date
38
+ ```
39
+
40
+ ## 按类型分类 (type)
41
+
42
+ 自动识别以下文件类型并分类到对应目录:
43
+
44
+ | 类别 | 支持的扩展名 |
45
+ |------|------------|
46
+ | 图片 | jpg, png, gif, webp, svg, bmp, tiff... |
47
+ | 文档 | pdf, doc, xls, ppt, txt, md, csv... |
48
+ | 压缩包 | zip, rar, 7z, tar, gz, bz2... |
49
+ | 视频 | mp4, avi, mkv, mov, flv... |
50
+ | 音频 | mp3, wav, flac, aac, ogg... |
51
+ | 代码 | py, js, java, go, rs, cpp, rb... |
52
+ | 网页 | html, css, scss... |
53
+ | 配置 | json, xml, yaml, toml, ini... |
54
+ | 可执行 | exe, msi, apk, deb, rpm... |
55
+ | 字体 | ttf, otf, woff... |
56
+
57
+ ## 按日期分类 (date)
58
+
59
+ 按文件的最后修改时间,自动以 `年-月` 格式分目录归档。
60
+
61
+ ## 特点
62
+
63
+ - 零配置,安装即用
64
+ - 自动处理重名文件(添加编号后缀)
65
+ - 安全移动,非复制
66
+ - 纯 Python,零依赖
67
+
68
+ ## 支持
69
+
70
+ 如果 file-org-kit 帮到了您,欢迎打赏支持:
71
+
72
+ ```
73
+ USDT (TRC20): TMPQygMkv42QPeyYnkxMkPwsqs7udbD2Aa
74
+ ```
75
+
76
+ 您的支持是开源项目持续发展的动力 ❤️
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ file_org/__init__.py
5
+ file_org/organizer.py
6
+ file_org_kit.egg-info/PKG-INFO
7
+ file_org_kit.egg-info/SOURCES.txt
8
+ file_org_kit.egg-info/dependency_links.txt
9
+ file_org_kit.egg-info/entry_points.txt
10
+ file_org_kit.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ file-org = file_org.organizer:main
@@ -0,0 +1 @@
1
+ file_org
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "file-org-kit"
7
+ version = "1.0.0"
8
+ description = "文件智能分类整理工具 - 按类型或日期自动归档文件,告别杂乱下载目录"
9
+ readme = "README.md"
10
+ authors = [
11
+ {name = "BoiledSaltedDuck", email = "tools@office-tools.pro"}
12
+ ]
13
+ license = {text = "MIT"}
14
+ keywords = ["file", "organize", "organizer", "分类", "整理", "归档"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Topic :: System :: Filesystems",
20
+ "Topic :: Utilities",
21
+ ]
22
+ requires-python = ">=3.7"
23
+ dependencies = []
24
+
25
+ [project.scripts]
26
+ file-org = "file_org.organizer:main"
27
+
28
+ [tool.setuptools.packages.find]
29
+ include = ["file_org*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+