npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

friday-file-organizer-cli

v1.0.0

Published

A CLI tool to organize files by creation time into monthly folders

Readme

File Organizer CLI - Node.js 版本

一个基于 Node.js 的文件整理命令行工具,可以按创建时间自动将文件按月份分组整理。

📦 安装

全局安装(推荐)

npm install -g file-organizer-cli

本地安装

npm install file-organizer-cli

从源码安装

git clone https://github.com/yourusername/file-organizer-cli.git
cd file-organizer-cli
npm install -g .

# 安装后使用
friday --help

🚀 快速开始

# 基本用法:整理当前目录的图片文件
friday

# 查看帮助
friday --help

# 查看版本
friday --version

📖 完整使用指南

基本命令

# 整理当前目录
friday organize

# 整理指定目录
friday organize --source ./my-photos

# 整理指定类型的文件
friday organize --extensions .jpg,.png,.pdf

# 指定目标目录
friday organize --target ~/MyArchive

参数说明

| 参数 | 别名 | 默认值 | 说明 | | --- | --- | --- | --- | | --source | -s | 当前目录 | 源目录路径 | | --extensions | -e | 常见图片格式 | 文件扩展名,逗号分隔 | | --target | -t | 用户目录/FileOrganizer | 目标目录路径 | | --tool-dir | -d | FileOrganizer | 工具专属目录名 | | --dry-run | -n | false | 试运行模式,不实际执行 | | --verbose | -v | false | 详细输出模式 | | --list | -l | false | 仅列出待整理文件 | | --group-by | -g | month | 分组方式:day, month, quarter, year | | --preserve-path | -p | false | 保留源目录结构 | | --min-size | | 0 | 最小文件大小(字节) | | --max-size | | Infinity | 最大文件大小(字节) | | --skip-existing | | false | 跳过已存在的文件 | | --output-format | -o | json | 输出格式:json, text, csv | | --config | | | 配置文件路径 |

使用示例

示例 1:整理个人照片库

# 整理照片并保留原始目录结构
friday organize \
  --source ~/Pictures \
  --extensions .jpg,.jpeg,.png,.heic,.raw \
  --target ~/PhotoArchive \
  --preserve-path \
  --verbose

示例 2:工作文件季度归档

# 按季度整理工作文档
friday organize \
  --source ./工作文档 \
  --extensions .docx,.xlsx,.pptx,.pdf \
  --group-by quarter \
  --dry-run \
  --verbose

示例 3:批量整理多种文件

# 整理大文件并跳过已存在的
friday organize \
  --source ~/Downloads \
  --extensions .mp4,.zip,.dmg,.iso \
  --min-size 10485760 \
  --skip-existing \
  --output-format csv

示例 4:创建配置文件并批量处理

# 生成配置文件模板
friday init-config

# 使用配置文件
friday organize --config ./organizer-config.json

⚙️ 配置文件

配置文件示例 (organizer-config.json)

{
  "version": "1.0.0",
  "defaults": {
    "name": "整理照片",
    "source": "./",
    "extensions": [".jpg", ".jpeg", ".png", ".gif"],
    "target": "~/FileOrganizer",
    "groupBy": "month",
    "dryRun": false,
    "verbose": false,
    "timestampSource": "created",
    "action": "copy"
  },
  "exclude": {
    "directories": [".git", "node_modules", ".DS_Store"],
    "patterns": ["**/temp/*", "**/*.tmp"]
  }
}

生成配置文件

# 生成默认配置文件
friday init-config

# 生成带示例的配置文件
friday init-config --example

# 指定配置文件名
friday init-config --filename my-config.json

📊 输出格式

JSON 格式输出

friday organize --output-format json
{
  "status": "success",
  "stats": {
    "totalFiles": 156,
    "organized": 152,
    "skipped": 3,
    "errors": 1,
    "totalSize": "245.7 MB"
  },
  "groups": {
    "2024-01": 45,
    "2024-02": 67,
    "2024-03": 40
  },
  "destination": "~/FileOrganizer",
  "duration": "12.5s"
}

CSV 格式输出

friday organize --output-format csv > report.csv

Text 格式输出(默认)

friday organize --output-format text

🔧 API 使用

作为模块使用

const { FileOrganizer } = require('file-organizer-cli');

// 创建整理器实例
const organizer = new FileOrganizer({
  source: './photos',
  extensions: ['.jpg', '.png'],
  target: '~/PhotoArchive',
  groupBy: 'month'
});

// 整理文件
organizer.organize()
  .then(stats => {
    console.log('整理完成:', stats);
  })
  .catch(error => {
    console.error('整理失败:', error);
  });

高级 API 使用

const { FileScanner, FileGrouper, FileMover } = require('file-organizer-cli');

// 自定义整理流程
async function customOrganize(options) {
  const scanner = new FileScanner(options.source);
  const files = await scanner.scan({
    extensions: options.extensions,
    minSize: options.minSize,
    maxSize: options.maxSize
  });

  const grouper = new FileGrouper(files);
  const groups = grouper.groupBy(options.groupBy);

  const mover = new FileMover(options.target);
  const results = await mover.moveGroups(groups, {
    dryRun: options.dryRun,
    skipExisting: options.skipExisting
  });

  return results;
}

🧪 测试

# 运行测试
npm test

# 运行特定测试
npm test -- --testNamePattern="扫描测试"

# 生成测试报告
npm test -- --coverage

📄 许可证

MIT License

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📞 支持

如有问题或建议,欢迎在 GitHub 仓库提交 Issue。