← 返回
未分类

skill1

Sort files in a directory into categorized subdirectories by file type
Sort files in a directory into categorized subdirectories by file type
user_60efd670
未分类 community v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 80
下载
💾 0
安装
1
版本
#latest

概述

File Organizer Skill

Organize files in a specified directory by sorting them into categorized subdirectories (Images, Documents, Audio, Video, Archives, Code, Others).

Usage

Invoke with: /organize-files [path] [flags]

  • path: Target directory (default: current working directory)
  • Flags:
  • --dry-run / -d: Preview changes without moving files
  • --flat / -f: Don't nest — move everything to current dir categories
  • --undo: Move files back to their original locations (uses a .file-organizer-log.json manifest)
  • --exclude-ext / -e: Comma-separated extensions to skip (e.g. -e .tmp,.log)

File Categorization Rules

Extension matching is case-insensitive.

CategoryExtensions
------------------------
Images.jpg .jpeg .png .gif .bmp .svg .webp .ico .tiff .psd .raw
Documents.pdf .doc .docx .xls .xlsx .ppt .pptx .txt .rtf .odt .ods .csv .md
Audio.mp3 .wav .flac .aac .ogg .m4a .wma .opus
Video.mp4 .avi .mkv .mov .wmv .flv .webm .mts
Archives.zip .rar .7z .tar .gz .bz2 .xz .zst
Code.py .js .ts .jsx .tsx .java .cpp .c .h .hpp .go .rs .swift .kt .scala .rb .php .pl .lua .sh .ps1 .bat .html .css .scss .less .sql .json .xml .yaml .yml .toml .ini .cfg .dockerfile .makefile .gradle
Executables.exe .msi .dll .so .dylib .bin .appimage
OthersEverything not matched above

Behavior

  1. Scan the target directory (non-recursive by default; only top-level files)
  2. Categorize each file by its extension
  3. Create category subdirectories if they don't exist
  4. Move files into corresponding directories
  5. Write a manifest file .file-organizer-log.json in the target directory (for --undo)
  6. Print a summary of what was moved

Safety

  • Never move files that are currently open/locked (check with a Test-Path variant or try/catch)
  • Never move .file-organizer-log.json itself
  • Skip hidden files (starting with .)
  • When moving, handle name collisions by appending a number suffix (e.g. photo (2).jpg)
  • --dry-run must not modify any files
  • --undo reads the manifest and moves each file back; delete the manifest on successful undo

Examples

/organize-files                     # organize the current directory
/organize-files D:\Downloads        # organize a specific folder
/organize-files -d                  # preview only
/organize-files --exclude-ext .ini,.cfg  # skip config files
/organize-files --undo              # roll back the last organization

Implementation

Use PowerShell with the following helper approach:

$categories = @{
    'Images' = @('.jpg','.jpeg','.png','.gif','.bmp','.svg','.webp','.ico','.tiff','.psd','.raw')
    'Documents' = @('.pdf','.doc','.docx','.xls','.xlsx','.ppt','.pptx','.txt','.rtf','.odt','.ods','.csv','.md')
    'Audio' = @('.mp3','.wav','.flac','.aac','.ogg','.m4a','.wma','.opus')
    'Video' = @('.mp4','.avi','.mkv','.mov','.wmv','.flv','.webm','.mts')
    'Archives' = @('.zip','.rar','.7z','.tar','.gz','.bz2','.xz','.zst')
    'Code' = @('.py','.js','.ts','.jsx','.tsx','.java','.cpp','.c','.h','.hpp','.go','.rs','.swift','.kt','.scala','.rb','.php','.pl','.lua','.sh','.ps1','.bat','.html','.css','.scss','.less','.sql','.json','.xml','.yaml','.yml','.toml','.ini','.cfg','.dockerfile','.makefile','.gradle')
    'Executables' = @('.exe','.msi','.dll','.so','.dylib','.bin','.appimage')
}

For each file: get extension, find matching category, create directory if needed, Move-Item with error handling. Write summary table.

版本历史

共 1 个版本

  • v1.0.0 Initial release 当前
    2026-05-17 16:45 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 932 📥 187,331
office-efficiency

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 464 📥 155,086
office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 387 📥 147,401