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

file-name-translator

v1.0.0

Published

A CLI tool to translate file names from Chinese/numbers to English equivalents

Readme

File Name Translator (FNT)

一个强大的命令行工具,用于将文件名从中文、数字或其他复杂格式自动翻译为标准英文名称。

✨ 特性

  • 🌏 智能翻译: 支持中文到英文的智能翻译
  • 🔢 数字转换: 将数字转换为对应的英文单词
  • 📁 批量处理: 支持递归处理整个目录结构
  • 🛡️ 安全检查: 内置安全机制,防止误操作系统文件
  • 🔍 预览模式: 在实际执行前预览所有变更
  • 💾 备份功能: 可选择在重命名前创建备份
  • 高性能: 异步处理,支持大量文件
  • 🎯 灵活过滤: 支持包含/排除模式
  • 📊 详细统计: 提供处理结果统计信息

🚀 安装

全局安装 (推荐)

npm install -g file-name-translator

本地安装

npm install file-name-translator

📖 使用方法

基本用法

# 翻译当前目录下的所有文件
fnt translate

# 翻译指定目录
fnt translate -d /path/to/directory

# 递归处理子目录
fnt translate -r

# 预览模式(不实际重命名)
fnt translate --dry-run

高级用法

# 交互模式,逐个确认
fnt translate -i

# 创建备份
fnt translate --backup

# 排除特定文件类型
fnt translate --exclude "*.log" "*.tmp"

# 只包含特定文件类型
fnt translate --include "*.txt" "*.md"

# 限制递归深度
fnt translate -r --max-depth 3

# 详细输出
fnt translate -v

# 强制执行(跳过确认)
fnt translate -f

预览功能

# 仅预览翻译结果
fnt preview

# 预览指定目录
fnt preview -d /path/to/directory

配置管理

# 配置翻译服务
fnt config

📋 命令选项

translate 命令

| 选项 | 简写 | 描述 | 默认值 | |------|------|------|--------| | --directory <path> | -d | 目标目录 | 当前目录 | | --recursive | -r | 递归处理子目录 | false | | --dry-run | | 预览模式,不实际重命名 | false | | --force | -f | 跳过确认提示 | false | | --exclude <patterns...> | | 排除模式(支持glob) | | | --include <patterns...> | | 包含模式(支持glob) | | | --backup | | 重命名前创建备份 | false | | --max-depth <number> | | 最大递归深度 | 10 | | --interactive | -i | 交互模式 | false | | --verbose | -v | 详细输出 | false |

🎯 翻译规则

中文翻译

工具内置了常用中文词汇的英文对应关系:

  • 文档document
  • 图片image
  • 项目project
  • 数据data
  • 配置config
  • 更多...

对于未预定义的中文,会使用拼音转换。

数字转换

  • 1one
  • 2two
  • 20twenty
  • 100one-hundred

格式化规则

  • 统一使用小写
  • 用连字符 (-) 替换空格和特殊字符
  • 移除不安全的文件名字符
  • 确保文件名符合跨平台兼容性

🛡️ 安全特性

系统目录保护

工具会自动识别并拒绝操作以下目录:

  • Windows: C:\Windows, C:\Program Files
  • macOS: /System, /Library, /Applications
  • Linux: /usr, /bin, /etc

冲突检测

  • 检测重命名后的文件名冲突
  • 验证目标文件是否已存在
  • 确保有足够的磁盘空间和权限

备份机制

使用 --backup 选项时,工具会:

  1. 在目标目录创建带时间戳的备份文件夹
  2. 复制所有即将重命名的文件
  3. 确保备份成功后才开始重命名

📊 使用示例

示例 1: 基本文件重命名

$ ls
我的文档.txt  照片1.jpg  项目数据.xlsx

$ fnt translate

🚀 File Name Translator Started
Found 3 files that may need translation

📋 Translation Preview:
1. 我的文档.txt → my-document.txt
2. 照片1.jpg → photo-one.jpg
3. 项目数据.xlsx → project-data.xlsx

✅ Rename 3 files? (Y/n) y

🎉 Translation completed!
✅ Successfully renamed: 3 files

示例 2: 递归处理项目目录

$ fnt translate -r -d ./我的项目 --backup -v

📊 Statistics:
  Total files processed: 45
  Successfully renamed: 42
  Conflicts resolved: 2
  Backup created: ./我的项目/.fnt-backup-1640995200000

示例 3: 预览模式

$ fnt preview -r

📋 Translation Preview:
1. 设计文档/界面设计.psd → design-document/interface-design.psd
2. 代码/主程序.js → code/main-program.js
3. 测试/单元测试1.js → test/unit-test-one.js

🔍 Dry run completed. No files were actually renamed.

⚙️ 配置文件

工具支持配置文件 ~/.fnt-config.json

{
  "translationService": "Built-in",
  "defaultOptions": {
    "recursive": true,
    "backup": true,
    "verbose": false
  },
  "customMappings": {
    "我的": "my",
    "新建": "new"
  }
}

🔧 开发

项目结构

file-name-translator/
├── src/
│   ├── index.ts          # 主入口
│   ├── translator.ts     # 翻译核心
│   ├── scanner.ts        # 文件扫描
│   ├── safety.ts         # 安全检查
│   └── logger.ts         # 日志工具
├── bin/
│   └── fnt.js           # 可执行入口
├── lib/                 # 编译输出
├── package.json
└── tsconfig.json

📝 更新日志

v1.0.0

  • 初始发布
  • 支持中文到英文翻译
  • 支持数字到英文单词转换
  • 内置安全检查机制
  • 支持批量处理和递归操作
  • 预览和备份功能

📄 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。