Command Palette

Search for a command to run...

Назад к скиллам
скилл № 00892

file-organizer

Organize and rename files based on content analysis. Use when a user asks to sort files into folders, rename files by pattern, organize a messy directory…

БесплатноБез исполняемых скриптов
TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Установить file-organizer в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

File Organizer

Overview

Organize, rename, and categorize files based on content analysis, metadata, and patterns. Handles messy directories by sorting files into logical folder structures, applying consistent naming conventions, and detecting duplicates. Works with any file type.

Instructions

When a user asks to organize files, determine which operation they need:

Task A: Sort files by type into folders

#!/bin/bash
# organize_by_type.sh - Sort files into folders by extension
SOURCE_DIR="${1:-.}"
DRY_RUN="${2:-false}"

declare -A TYPE_MAP=(
  # Documents
  ["pdf"]="Documents/PDF" ["docx"]="Documents/Word" ["doc"]="Documents/Word"
  ["xlsx"]="Documents/Excel" ["csv"]="Documents/CSV" ["txt"]="Documents/Text"
  # Images
  ["jpg"]="Images" ["jpeg"]="Images" ["png"]="Images"
  ["gif"]="Images" ["svg"]="Images" ["webp"]="Images"
  # Video
  ["mp4"]="Video" ["mkv"]="Video" ["avi"]="Video" ["mov"]="Video"
  # Audio
  ["mp3"]="Audio" ["wav"]="Audio" ["flac"]="Audio"
  # Code
  ["py"]="Code/Python" ["js"]="Code/JavaScript" ["ts"]="Code/TypeScript"
  # Archives
  ["zip"]="Archives" ["tar"]="Archives" ["gz"]="Archives" ["rar"]="Archives"
)

find "$SOURCE_DIR" -maxdepth 1 -type f | while read -r file; do
  ext="${file##*.}"
  ext="${ext,,}"  # lowercase
  dest="${TYPE_MAP[$ext]:-Other}"

  if [ "$DRY_RUN" = "true" ]; then
    echo "[DRY RUN] $file -> $SOURCE_DIR/$dest/"
  else
    mkdir -p "$SOURCE_DIR/$dest"
    # -n: never overwrite a file that already sits in the destination
    mv -n "$file" "$SOURCE_DIR/$dest/"
    echo "Moved: $(basename "$file") -> $dest/"
  fi
done

Task B: Smart rename based on patterns

import os
import re
from pathlib import Path
from datetime import datetime

def rename_by_pattern(directory: str, pattern: str, dry_run: bool = True):
    """
    Rename files using pattern substitution.
    Patterns: {date}, {n}, {ext}, {name}, {YYYY}, {MM}, {DD}
    {date} and {YYYY}/{MM}/{DD} use the file's modification time (st_mtime),
    not the EXIF capture date. Photos copied or edited after the shot get the
    copy date; read DateTimeOriginal with an EXIF library if you need the shot date.
    """
    files = sorted(Path(directory).iterdir())
    files = [f for f in files if f.is_file()]

    for i, filepath in enumerate(files, 1):
        stat = filepath.stat()
        mtime = datetime.fromtimestamp(stat.st_mtime)

        new_name = pattern
        new_name = new_name.replace("{name}", filepath.stem)
        new_name = new_name.replace("{ext}", filepath.suffix)
        new_name = new_name.replace("{n}", str(i).zfill(3))
        new_name = new_name.replace("{date}", mtime.strftime("%Y-%m-%d"))
        new_name = new_name.replace("{YYYY}", str(mtime.year))
        new_name = new_name.replace("{MM}", str(mtime.month).zfill(2))
        new_name = new_name.replace("{DD}", str(mtime.day).zfill(2))

        new_path = filepath.parent / new_name
        if new_path.exists():
            # Path.rename() silently replaces an existing file on POSIX; refuse instead
            print(f"  SKIP {filepath.name}: {new_name} already exists")
            continue
        if dry_run:
            print(f"  {filepath.name} -> {new_name}")
        else:
            filepath.rename(new_path)
            print(f"  Renamed: {filepath.name} -> {new_name}")

# Example: rename photos to date-based names
rename_by_pattern("./photos", "{date}_photo_{n}{ext}", dry_run=True)

Task C: Content-based organization using file metadata

import os
import shutil
from pathlib import Path
from datetime import datetime

def organize_by_date(directory: str, date_format: str = "%Y/%Y-%m"):
    """Sort files into year/year-month folders based on modification date."""
    # list() first: moving files while iterating the directory is fragile
    for filepath in list(Path(directory).iterdir()):
        if not filepath.is_file() or filepath.name.startswith('.'):
            continue
        mtime = datetime.fromtimestamp(filepath.stat().st_mtime)
        dest_dir = Path(directory) / mtime.strftime(date_format)
        target = dest_dir / filepath.name
        if target.exists():
            print(f"  SKIP {filepath.name}: already in {dest_dir}/")
            continue
        dest_dir.mkdir(parents=True, exist_ok=True)
        shutil.move(str(filepath), str(target))
        print(f"  {filepath.name} -> {dest_dir}/")

def organize_by_size(directory: str):
    """Sort files into small/medium/large folders."""
    size_buckets = [
        (1_000_000, "small_under_1MB"),
        (100_000_000, "medium_1MB_to_100MB"),
        (float('inf'), "large_over_100MB")
    ]
    for filepath in Path(directory).iterdir():
        if not filepath.is_file():
            continue
        size = filepath.stat().st_size
        for threshold, folder in size_buckets:
            if size < threshold:
                dest = Path(directory) / folder
                dest.mkdir(exist_ok=True)
                shutil.m
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • _scores.json

FAQ

Что делает скилл file-organizer?

Organize and rename files based on content analysis. Use when a user asks to sort files into folders, rename files by pattern, organize a messy directory, categorize documents by type or content, deduplicate files, or clean up a downloads folder. Handles smart renaming, content-based sorting, and duplicate detection.

Как установить скилл file-organizer?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл file-organizer запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить file-organizer с