coscmd icon indicating copy to clipboard operation
coscmd copied to clipboard

coscmd upload --ignore 是否支持忽略目录

Open MCC-NO1 opened this issue 4 years ago • 4 comments

coscmd upload 想忽略一些目录应该如何实现?

MCC-NO1 avatar May 12 '20 10:05 MCC-NO1

coscmd upload path path --ignore prefix/*

lewzylu avatar May 12 '20 10:05 lewzylu

--include 无法找到指定目录的指定格式文件。

简单介绍一下使用 coscmd 的初衷,我想同步上传 (-s sync), 因为 hugo 目录下包含了视频大文件 (不想上传至 github),所以在 gitignore 里剔除了。取而代之的,用 coscmd 手动单独把视频再上传一次; 因为需要保留文件层级,使用了 recursive -r; 但需要剔除除视频文件的其他文件,所以就用了 -- include

操作环境: M1 MacBook Air, 11.5.1, coscmd: coscmd 1.8.6.24

coscmd upload -rs /path/to/root/hugo-project/  / --include *.mp4,*.mov,*.webm

但返回

no matches found: *.mp4,*.mov,*.webm

/path/to/root/hugo-project/ 目录下是有存在 .mp4 文件的。

@lewzylu 请问这是哪里操作出了问题吗?

sarkrui avatar Aug 03 '21 15:08 sarkrui

自问自答,macOS Shell 下需要对后缀名加双引号包括,示例:

coscmd upload -rs /path/to/root/hugo-project/  / --include ”*.mp4,*.mov,*.webm”

sarkrui avatar Aug 05 '21 05:08 sarkrui

coscmd 是使用 Python 标准库的 fnmatch.fnmatch 函数判断文件名是否匹配的。fnmatch 函数不会对 / 作单独处理,而是把它当作文件名的一部分,按照匹配文件名的方式进行匹配。

由此可以总结出 coscmd 通配符的常见用法如下:

  • 忽略当前目录下的 index.js 文件:./index.js
  • 忽略所有 index.js 文件:*/index.js
  • 忽略当前目录下的 *.csv 文件:./*.csv
  • 忽略所有 *.csv 文件:*.csv
  • 忽略当前目录下的 test 子目录:./test/*
  • 忽略所有 test 子目录:*/test/*
  • 忽略所有 dot file:*/.*

详见《腾讯云 coscmd 通配符格式》。

ayaka14732 avatar Feb 28 '22 17:02 ayaka14732