Skill: xueyetianya/tidyfiles (version 2.0.0)

--- version: "2.0.0" name: tidyfiles description: "Sort and organize files into folders by type, date, or rules. Use when decluttering dirs, checking structure, running cleanup, generating reports." --- # Tidyfiles A versatile utility toolkit for recording, tracking, and managing file organization tasks from the command line. Each command logs timestamped entries to its own dedicated log file, with built-in statistics, multi-format export, search, and health-check capabilities. ## Why Tidyfiles? - Works entirely offline — your data stays on your machine - Each command type maintains its own log file for clean data separation - Built-in multi-format export (JSON, CSV, plain text) - Full activity history with timestamped audit trail - Search across all log files instantly - Summary statistics with entry counts and disk usage - Zero external dependencies — pure bash ## Commands ### Core Operations | Command | Description | |---------|-------------| | `tidyfiles run <input>` | Record a run entry (no args: show recent entries) | | `tidyfiles check <input>` | Record a check entry (no args: show recent entries) | | `tidyfiles convert <input>` | Record a convert entry (no args: show recent entries) | | `tidyfiles analyze <input>` | Record an analyze entry (no args: show recent entries) | | `tidyfiles generate <input>` | Record a generate entry (no args: show recent entries) | | `tidyfiles preview <input>` | Record a preview entry (no args: show recent entries) | | `tidyfiles batch <input>` | Record a batch entry (no args: show recent entries) | | `tidyfiles compare <input>` | Record a compare entry (no args: show recent entries) | | `tidyfiles export <input>` | Record an export entry (no args: show recent entries) | | `tidyfiles config <input>` | Record a config entry (no args: show recent entries) | | `tidyfiles status <input>` | Record a status entry (no args: show recent entries) | | `tidyfiles report <input>` | Record a report entry (no args: show recent entries) | ### Utility Commands | Command | Description | |---------|-------------| | `tidyfiles stats` | Show summary statistics (entry counts per type, total, disk usage) | | `tidyfiles export <fmt>` | Export all data in json, csv, or txt format | | `tidyfiles search <term>` | Search across all log files (case-insensitive) | | `tidyfiles recent` | Show the 20 most recent activity log entries | | `tidyfiles status` | Health check (version, entries, disk, last activity) | | `tidyfiles help` | Display all available commands | | `tidyfiles version` | Print version string | Each core command works in two modes: - **With arguments**: Saves a timestamped entry to `<command>.log` and logs to `history.log` - **Without arguments**: Displays the 20 most recent entries from that command's log ## Data Storage All data is stored locally in `~/.local/share/tidyfiles/`. The directory contains: - **`run.log`**, **`check.log`**, **`convert.log`**, **`analyze.log`**, etc. — One log file per command type, storing `YYYY-MM-DD HH:MM|input` entries - **`history.log`** — Unified activity log with timestamped records of every command executed - **`export.json`** / **`export.csv`** / **`export.txt`** — Generated export files ## Requirements - **Bash** 4.0+ with `set -euo pipefail` strict mode - Standard Unix utilities: `grep`, `cat`, `tail`, `wc`, `du`, `date`, `sed` - No external dependencies or network access required ## When to Use 1. **Tracking file organization tasks** — Use `tidyfiles run "sorted ~/Downloads by file type"` to log cleanup activities with timestamps 2. **Checking directory structure** — Record structure checks with `tidyfiles check "~/projects: 45 dirs, 230 files, no empty dirs"` 3. **Analyzing disk usage patterns** — Log analysis results with `tidyfiles analyze "Documents folder: 12GB, 40% PDFs"` and review with `tidyfiles search "Documents"` 4. **Batch file operations** — Track batch processing with `tidyfiles batch "renamed 150 photos with date prefix"` and review past batches 5. **Generating cleanup reports** — Use `tidyfiles report "weekly cleanup: freed 3.2GB"` then `tidyfiles export csv` for spreadsheet analysis ## Examples ```bash # Record file organization activities tidyfiles run "organized Downloads into subfolders" tidyfiles check "verified backup integrity: 100% match" tidyfiles analyze "home directory: 85GB used, 15GB free" # Track conversions and batch operations tidyfiles convert "batch converted 200 PNGs to WebP" tidyfiles batch "moved archived projects to cold storage" tidyfiles generate "created folder structure for new project" # Preview and compare tidyfiles preview "dry-run sort of ~/Desktop: 45 files to move" tidyfiles compare "before/after cleanup: 12GB freed" # Search, review, and export tidyfiles search "backup" tidyfiles recent tidyfiles stats tidyfiles export json tidyfiles export csv # Configuration and reporting tidyfiles config "default sort: by extension" tidyfiles report "monthly cleanup summary: 25GB reclaimed" tidyfiles status ``` ## Configuration The data directory defaults to `~/.local/share/tidyfiles/`. All log files are plain text with pipe-delimited fields (`timestamp|value`), making them easy to parse with standard Unix tools or import into spreadsheets. --- Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]

path: scripts/script.sh
content: #!/usr/bin/env bash
# Tidyfiles — utility tool
# Powered by BytesAgain | bytesagain.com | [REDACTED_SECRET]
set -euo pipefail

DATA_DIR="${HOME}/.local/share/tidyfiles"
mkdir -p "$DATA_DIR"

_log() { echo "$(date '+%m-%d %H:%M') $1: $2" >> "$DATA_DIR/history.log"; }
_version() { echo "tidyfiles v2.0.0"; }

_help() {
    echo "Tidyfiles v2.0.0 — utility toolkit"
    echo ""
    echo "Usage: tidyfiles <command> [args]"
    echo ""
    echo "Commands:"
    echo "  run                Run"
    echo "  check              Check"
    echo "  convert            Convert"
    echo "  analyze            Analyze"
    echo "  generate           Generate"
    echo "  preview            Preview"
    echo "  batch              Batch"
    echo "  compare            Compare"
    echo "  export             Export"
    echo "  config             Config"
    echo "  status             Status"
    echo "  report             Report"
    echo "  stats              Summary statistics"
    echo "  export <fmt>       Export (json|csv|txt)"
    echo "  search <term>      Search entries"
    echo "  recent             Recent activity"
    echo "  status             Health check"
    echo "  help               Show this help"
    echo "  version            Show version"
    echo ""
    echo "Data: $DATA_DIR"
}

_stats() {
    echo "=== Tidyfiles Stats ==="
    local total=0
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local name=$(basename "$f" .log)
        local c=$(wc -l < "$f")
        total=$((total + c))
        echo "  $name: $c entries"
    done
    echo "  ---"
    echo "  Total: $total entries"
    echo "  Data size: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
}

_export() {
    local fmt="${1:-json}"
    local out="$DATA_DIR/export.$fmt"
    case "$fmt" in
        json)
            echo "[" > "$out"
            local first=1
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do
                    [ $first -eq 1 ] && first=0 || echo "," >> "$out"
                    printf '  {"type":"%s","time":"%s","value":"%s"}' "$name" "$ts" "$val" >> "$out"
                done < "$f"
            done
            echo "\n]" >> "$out"
            ;;
        csv)
            echo "type,time,value" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                local name=$(basename "$f" .log)
                while IFS='|' read -r ts val; do echo "$name,$ts,$val" >> "$out"; done < "$f"
            done
            ;;
        txt)
            echo "=== Tidyfiles Export ===" > "$out"
            for f in "$DATA_DIR"/*.log; do
                [ -f "$f" ] || continue
                echo "--- $(basename "$f" .log) ---" >> "$out"
                cat "$f" >> "$out"
            done
            ;;
        *) echo "Formats: json, csv, txt"; return 1 ;;
    esac
    echo "Exported to $out ($(wc -c < "$out") bytes)"
}

_status() {
    echo "=== Tidyfiles Status ==="
    echo "  Version: v2.0.0"
    echo "  Data dir: $DATA_DIR"
    echo "  Entries: $(cat "$DATA_DIR"/*.log 2>/dev/null | wc -l) total"
    echo "  Disk: $(du -sh "$DATA_DIR" 2>/dev/null | cut -f1)"
    echo "  Last: $(tail -1 "$DATA_DIR/history.log" 2>/dev/null || echo never)"
    echo "  Status: OK"
}

_search() {
    local term="${1:?Usage: tidyfiles search <term>}"
    echo "Searching for: $term"
    for f in "$DATA_DIR"/*.log; do
        [ -f "$f" ] || continue
        local m=$(grep -i "$term" "$f" 2>/dev/null || true)
        if [ -n "$m" ]; then
            echo "  --- $(basename "$f" .log) ---"
            echo "$m" | sed 's/^/    /'
        fi
    done
}

_recent() {
    echo "=== Recent Activity ==="
    tail -20 "$DATA_DIR/history.log" 2>/dev/null | sed 's/^/  /' || echo "  No activity yet."
}

case "${1:-help}" in
    run)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent run entries:"
            tail -20 "$DATA_DIR/run.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles run <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/run.log"
            local total=$(wc -l < "$DATA_DIR/run.log")
            echo "  [Tidyfiles] run: $input"
            echo "  Saved. Total run entries: $total"
            _log "run" "$input"
        fi
        ;;
    check)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent check entries:"
            tail -20 "$DATA_DIR/check.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles check <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/check.log"
            local total=$(wc -l < "$DATA_DIR/check.log")
            echo "  [Tidyfiles] check: $input"
            echo "  Saved. Total check entries: $total"
            _log "check" "$input"
        fi
        ;;
    convert)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent convert entries:"
            tail -20 "$DATA_DIR/convert.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles convert <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/convert.log"
            local total=$(wc -l < "$DATA_DIR/convert.log")
            echo "  [Tidyfiles] convert: $input"
            echo "  Saved. Total convert entries: $total"
            _log "convert" "$input"
        fi
        ;;
    analyze)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent analyze entries:"
            tail -20 "$DATA_DIR/analyze.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles analyze <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/analyze.log"
            local total=$(wc -l < "$DATA_DIR/analyze.log")
            echo "  [Tidyfiles] analyze: $input"
            echo "  Saved. Total analyze entries: $total"
            _log "analyze" "$input"
        fi
        ;;
    generate)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent generate entries:"
            tail -20 "$DATA_DIR/generate.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles generate <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/generate.log"
            local total=$(wc -l < "$DATA_DIR/generate.log")
            echo "  [Tidyfiles] generate: $input"
            echo "  Saved. Total generate entries: $total"
            _log "generate" "$input"
        fi
        ;;
    preview)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent preview entries:"
            tail -20 "$DATA_DIR/preview.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles preview <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/preview.log"
            local total=$(wc -l < "$DATA_DIR/preview.log")
            echo "  [Tidyfiles] preview: $input"
            echo "  Saved. Total preview entries: $total"
            _log "preview" "$input"
        fi
        ;;
    batch)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent batch entries:"
            tail -20 "$DATA_DIR/batch.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles batch <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/batch.log"
            local total=$(wc -l < "$DATA_DIR/batch.log")
            echo "  [Tidyfiles] batch: $input"
            echo "  Saved. Total batch entries: $total"
            _log "batch" "$input"
        fi
        ;;
    compare)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent compare entries:"
            tail -20 "$DATA_DIR/compare.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles compare <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/compare.log"
            local total=$(wc -l < "$DATA_DIR/compare.log")
            echo "  [Tidyfiles] compare: $input"
            echo "  Saved. Total compare entries: $total"
            _log "compare" "$input"
        fi
        ;;
    export)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent export entries:"
            tail -20 "$DATA_DIR/export.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles export <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/export.log"
            local total=$(wc -l < "$DATA_DIR/export.log")
            echo "  [Tidyfiles] export: $input"
            echo "  Saved. Total export entries: $total"
            _log "export" "$input"
        fi
        ;;
    config)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent config entries:"
            tail -20 "$DATA_DIR/config.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles config <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/config.log"
            local total=$(wc -l < "$DATA_DIR/config.log")
            echo "  [Tidyfiles] config: $input"
            echo "  Saved. Total config entries: $total"
            _log "config" "$input"
        fi
        ;;
    status)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent status entries:"
            tail -20 "$DATA_DIR/status.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles status <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/status.log"
            local total=$(wc -l < "$DATA_DIR/status.log")
            echo "  [Tidyfiles] status: $input"
            echo "  Saved. Total status entries: $total"
            _log "status" "$input"
        fi
        ;;
    report)
        shift
        if [ $# -eq 0 ]; then
            echo "Recent report entries:"
            tail -20 "$DATA_DIR/report.log" 2>/dev/null || echo "  No entries yet. Use: tidyfiles report <input>"
        else
            local input="$*"
            local ts=$(date '+%Y-%m-%d %H:%M')
            echo "$ts|$input" >> "$DATA_DIR/report.log"
            local total=$(wc -l < "$DATA_DIR/report.log")
            echo "  [Tidyfiles] report: $input"
            echo "  Saved. Total report entries: $total"
            _log "report" "$input"
        fi
        ;;
    stats) _stats ;;
    export) shift; _export "$@" ;;
    search) shift; _search "$@" ;;
    recent) _recent ;;
    status) _status ;;
    help|--help|-h) _help ;;
    version|--version|-v) _version ;;
    *)
        echo "Unknown: $1 — run 'tidyfiles help'"
        exit 1
        ;;
esac

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)