3m 中文文档教程

发布于 6年前 浏览 30 项目主页 更新于 3年前

3m (Move & Minify Medias)

缩小图像(jpg、png)并按照模式重命名它们

Install

npm install -g 3m

Usage

3m [options] <; 文件或 glob ... >

Options

  • -v, --version

  • -o, --output-dir <目标目录>
    默认值:./dist

  • -p, --pattern
    设置文件名、可用模式:[NAME]、[EXT]、[INDEX]、[DIRNAME]、[INDEXIN_DIR]
    默认值:[NAME][EXT]

  • -e, --extensions
    设置扩展
    默认值:jpg,jpeg,png

  • -r, --recursive

  • --no-clear
    不要清除目标目录

  • --no-minify
    不要缩小媒体

  • -h, --help

Examples

给定以下结构:

.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify and move all files to a single directory

3m -r --extensions=jpg,mp4
.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── dist
│&nbsp;&nbsp; ├── [1.2M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [726K]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; ├── [916K]  IMG_20180423_141640.jpg
│&nbsp;&nbsp; ├── [1.0M]  IMG_20180423_141759.jpg
│&nbsp;&nbsp; ├── [1.2M]  IMG_20180423_142342.jpg
│&nbsp;&nbsp; ├── [1.0M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [1.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; ├── [975K]  IMG_20180423_143339.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify, move and rename all files

3m -r --extensions=jpg,mp4 --pattern [DIR_NAME]_[INDEX_IN_DIR][EXT]
.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── dist
│&nbsp;&nbsp; ├── [1.2M]  canada_1.jpg
│&nbsp;&nbsp; ├── [726K]  canada_2.jpg
│&nbsp;&nbsp; ├── [ 37M]  canada_3.mp4
│&nbsp;&nbsp; ├── [1.0M]  france_1.jpg
│&nbsp;&nbsp; ├── [1.1M]  france_2.jpg
│&nbsp;&nbsp; ├── [975K]  france_3.jpg
│&nbsp;&nbsp; ├── [916K]  japan_1.jpg
│&nbsp;&nbsp; ├── [1.0M]  japan_2.jpg
│&nbsp;&nbsp; └── [1.2M]  japan_3.jpg
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify, move and rename some files/directory

3m -r --extensions=jpg,mp4 --pattern [DIR_NAME]_[INDEX_IN_DIR][EXT] canada japan/IMG_20180423_141640.jpg france/IMG_20180423_143339.jpg
.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── dist
│&nbsp;&nbsp; ├── [1.2M]  canada_1.jpg
│&nbsp;&nbsp; ├── [726K]  canada_2.jpg
│&nbsp;&nbsp; ├── [ 37M]  canada_3.mp4
│&nbsp;&nbsp; ├── [975K]  france_1.jpg
│&nbsp;&nbsp; └── [916K]  japan_1.jpg
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify, move and keep the same structure

3m -r --pattern [PATH]/[NAME][EXT] --extensions=jpg,mp4
.
├── canada
│&nbsp;&nbsp; ├── IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── VID_20180424_144512.mp4
├── dist
│&nbsp;&nbsp; ├── canada
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180422_173241.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180423_135753.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; └── VID_20180424_144512.mp4
│&nbsp;&nbsp; ├── france
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180423_143133.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180423_143339.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; └── IMG_20180423_144710.jpg
│&nbsp;&nbsp; └── japan
│&nbsp;&nbsp;     ├── IMG_20180422_173241.jpg
│&nbsp;&nbsp;     ├── IMG_20180423_135753.jpg
│&nbsp;&nbsp;     └── IMG_20180423_141640.jpg
├── france
│&nbsp;&nbsp; ├── IMG_20180423_143133.jpg
│&nbsp;&nbsp; ├── IMG_20180423_143339.jpg
│&nbsp;&nbsp; └── IMG_20180423_144710.jpg
└── japan
    ├── IMG_20180422_173241.jpg
    ├── IMG_20180423_135753.jpg
    └── IMG_20180423_141640.jpg

3m (Move & Minify Medias)

Minify images (jpg, png) and rename them following a pattern

Install

npm install -g 3m

Usage

3m [options] < file or glob ... >

Options

  • -v, --version

  • -o, --output-dir <destination directory>
    Default: ./dist

  • -p, --pattern <pattern>
    Set files names, availables patterns : [NAME],[EXT],[INDEX],[DIRNAME],[INDEXIN_DIR]
    Default: [NAME][EXT]

  • -e, --extensions <extensions>
    Set extensions
    Default: jpg,jpeg,png

  • -r, --recursive

  • --no-clear
    Don't clear destination directory

  • --no-minify
    Don't minify medias

  • -h, --help

Examples

Given the following structure :

.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify and move all files to a single directory

3m -r --extensions=jpg,mp4
.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── dist
│&nbsp;&nbsp; ├── [1.2M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [726K]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; ├── [916K]  IMG_20180423_141640.jpg
│&nbsp;&nbsp; ├── [1.0M]  IMG_20180423_141759.jpg
│&nbsp;&nbsp; ├── [1.2M]  IMG_20180423_142342.jpg
│&nbsp;&nbsp; ├── [1.0M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [1.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; ├── [975K]  IMG_20180423_143339.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify, move and rename all files

3m -r --extensions=jpg,mp4 --pattern [DIR_NAME]_[INDEX_IN_DIR][EXT]
.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── dist
│&nbsp;&nbsp; ├── [1.2M]  canada_1.jpg
│&nbsp;&nbsp; ├── [726K]  canada_2.jpg
│&nbsp;&nbsp; ├── [ 37M]  canada_3.mp4
│&nbsp;&nbsp; ├── [1.0M]  france_1.jpg
│&nbsp;&nbsp; ├── [1.1M]  france_2.jpg
│&nbsp;&nbsp; ├── [975K]  france_3.jpg
│&nbsp;&nbsp; ├── [916K]  japan_1.jpg
│&nbsp;&nbsp; ├── [1.0M]  japan_2.jpg
│&nbsp;&nbsp; └── [1.2M]  japan_3.jpg
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify, move and rename some files/directory

3m -r --extensions=jpg,mp4 --pattern [DIR_NAME]_[INDEX_IN_DIR][EXT] canada japan/IMG_20180423_141640.jpg france/IMG_20180423_143339.jpg
.
├── canada
│&nbsp;&nbsp; ├── [4.8M]  IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── [3.4M]  IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── [ 37M]  VID_20180221_123547.mp4
├── dist
│&nbsp;&nbsp; ├── [1.2M]  canada_1.jpg
│&nbsp;&nbsp; ├── [726K]  canada_2.jpg
│&nbsp;&nbsp; ├── [ 37M]  canada_3.mp4
│&nbsp;&nbsp; ├── [975K]  france_1.jpg
│&nbsp;&nbsp; └── [916K]  japan_1.jpg
├── france
│&nbsp;&nbsp; ├── [4.3M]  IMG_20180423_143013.jpg
│&nbsp;&nbsp; ├── [4.1M]  IMG_20180423_143133.jpg
│&nbsp;&nbsp; └── [3.8M]  IMG_20180423_143339.jpg
└── japan
    ├── [4.0M]  IMG_20180423_141640.jpg
    ├── [4.4M]  IMG_20180423_141759.jpg
    └── [4.7M]  IMG_20180423_142342.jpg

Minify, move and keep the same structure

3m -r --pattern [PATH]/[NAME][EXT] --extensions=jpg,mp4
.
├── canada
│&nbsp;&nbsp; ├── IMG_20180422_173241.jpg
│&nbsp;&nbsp; ├── IMG_20180423_135753.jpg
│&nbsp;&nbsp; └── VID_20180424_144512.mp4
├── dist
│&nbsp;&nbsp; ├── canada
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180422_173241.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180423_135753.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; └── VID_20180424_144512.mp4
│&nbsp;&nbsp; ├── france
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180423_143133.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── IMG_20180423_143339.jpg
│&nbsp;&nbsp; │&nbsp;&nbsp; └── IMG_20180423_144710.jpg
│&nbsp;&nbsp; └── japan
│&nbsp;&nbsp;     ├── IMG_20180422_173241.jpg
│&nbsp;&nbsp;     ├── IMG_20180423_135753.jpg
│&nbsp;&nbsp;     └── IMG_20180423_141640.jpg
├── france
│&nbsp;&nbsp; ├── IMG_20180423_143133.jpg
│&nbsp;&nbsp; ├── IMG_20180423_143339.jpg
│&nbsp;&nbsp; └── IMG_20180423_144710.jpg
└── japan
    ├── IMG_20180422_173241.jpg
    ├── IMG_20180423_135753.jpg
    └── IMG_20180423_141640.jpg
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文