Rclone 命令详解
# 语法格式
rclone [可选参数] 子命令 <参数> <参数...>
# 子命令
示例
# 显示远端文件列表
rclone ls my-gdrive:path
# 上传 /path/to/file 到远端目录
rclone copy /path/to/file my-gdrive:path
# 同步 /path/to/xync 到远端目录
rclone sync -i /path/to/xync my-gdrive:path
2
3
4
5
6
常用子命令
rclone config - 进入配置会话
rclone copy - 复制,可以用来上传和下载文件
# 上传:rclone copy [本地文件路径] [网盘标识:网盘路径] $ rclone copy 测试.txt gdrive-geek:work/ # 下载:rclone copy [网盘标识:网盘路径(可以是文件夹)] [本地文件路径] $ rclone copy gdrive-geek:work/测试.txt 测试_下载.txt
1
2
3
4rclone ls - 列出指定目录(包括子目录)下的所有文件,并显示占用大小
# rclone ls [网盘标识:网盘路径] $ rclone ls gdrive-geek:work 23 测试.txt -1 part1/文档1.docx 29639 part1/ye.001.jpeg
1
2
3
4
5rclone lsl - 同
rclone ls
,增加了更新时间的显示rclone lsd - 列出指定目录下所有目录(不包括子目录),同时显示更新时间,用法参考
rclone ls
rclone lsf - 列出指定目录下所有目录(不包括子目录)和文件,不显示更新时间,用法参考
rclone ls
rclone tree - 列出指定路径下的所有文件和目录,以树形结构显示
# rclone tree [网盘标识:网盘路径] $ rclone tree gdrive-geek:work / ├── part1 │ ├── ye.001.jpeg │ └── 文档1.docx ├── part2 │ └── part1-1 │ └── 日程.xlsx └── 测试.txt
1
2
3
4
5
6
7
8
9
10rclone size - 查看指定目录或文件占用大小
# rclone size [网盘标识:网盘路径] $ rclone size gdrive-geek:work Total objects: 4 Total size: 28.967 kBytes (29662 Bytes)
1
2
3
4rclone move - 移动文件或文件夹(即:剪切)
# rclone move source:path dest:path [flags] rclone move gdrive-geek:work/part1/part1-1 gdrive-geek:work/part2/part1-1
1
2rclone sync
同步文件,包括本地同步到网盘和网盘同步到本地,第一个参数路径是源路径,第二个参数路径是目标路径。只同步有变更的文件,同步过程可能会删除文件,最好用
-n
或者--dry-run
先测试下执行过程# rclone sync source:path dest:path [flags] $ rclone sync /path/to/sync gdrive-geek:dest/path
1
2rclone delete - 删除路径下的文件
rclone delete gdrive-geek:work/part3
1rclone purge - 同
rclone delete
,不同的是会把文件夹也删除rclone mkdir - 创建目录
# rclone mkdir [网盘标识:网盘路径] rclone mkdir gdrive-geek:work/part3
1
2rclone rmdir - 删除目录
# rclone rmdir [网盘标识:网盘路径] [flags] rclone rmdir gdrive-geek:work/dir1
1
2rclone rmdirs - 删除指定目录下的空目录
# rclone rmdirs remote:path [flags] rclone rmdirs gdrive-geek:work
1
2
所有命令都可以执行rclone [cmd] -h
,查看对应命令帮助文档,如rclone copy -h
# 常用可选配置项
--config=CONFIG_FILE
指定配置文件路径,默认
~/.config/rclone/rclone.conf
-P, --progress
显示进度条
-n, --dry-run
测试执行,可以用来了解实际执行过程,这里并不会真的执行
--transfers=N
并行传输文件数量,默认是4
--log-file=FILE
日志输出到指定文件
--log-level LEVEL
指定输出日志级别,优先级从高到低:ERROR -> NOTICE -> INFO -> DEBUG,另外还可以简写成:
-q
等价于--log-level ERROR
-v
等价于--log-level INFO
-vv
等价于--log-level DEBUG
# 这写成 --log-level=DEBUG 也是可以的 rclone copy gdrive-geek:work/part1 ./part1 --log-level DEBUG --log-file=rclone.log
1
2
其他的还有很多,查看官方文档:https://rclone.org/docs/#options (opens new window)
# 文件过滤
--exclude
排除的文件或目录,例如:
rclone sync -i /path/to/local/file remote:current --exclude "*.bak"
--include
包含的文件或目录,用法跟
exclude
一样--filter
包括了
exclude
和include
两个功能,因为exclude
和include
不能同时使用,这个时候可以使用filter
,-
表示exclude
,+
表示include
,例如:--filter "- *.bak"
匹配字符串支持正则表达式,其他过滤参数,查看官方文档:https://rclone.org/filtering/ (opens new window)
# 其他命令
更多命令用法可执行rclone -h
可以查看说明,或者查看官方文档https://rclone.org/commands/ (opens new window)
➜ ~ rclone -h
Rclone syncs files to and from cloud storage providers as well as
mounting them, listing them in lots of different ways.
See the home page (https://rclone.org/) for installation, usage,
documentation, changelog and configuration walkthroughs.
Usage:
rclone [flags]
rclone [command]
Available Commands:
about Get quota information from the remote.
authorize Remote authorization.
backend Run a backend specific command.
cat Concatenates any files and sends them to stdout.
check Checks the files in the source and destination match.
cleanup Clean up the remote if possible.
cmount Mount the remote as file system on a mountpoint.
config Enter an interactive configuration session.
copy Copy files from source to dest, skipping already copied.
copyto Copy files from source to dest, skipping already copied.
copyurl Copy url content to dest.
cryptcheck Cryptcheck checks the integrity of a crypted remote.
cryptdecode Cryptdecode returns unencrypted file names.
dedupe Interactively find duplicate filenames and delete/rename them.
delete Remove the contents of path.
deletefile Remove a single file from remote.
genautocomplete Output completion script for a given shell.
gendocs Output markdown docs for rclone to the directory supplied.
hashsum Produces a hashsum file for all the objects in the path.
help Show help for rclone commands, flags and backends.
link Generate public link to file/folder.
listremotes List all the remotes in the config file.
ls List the objects in the path with size and path.
lsd List all directories/containers/buckets in the path.
lsf List directories and objects in remote:path formatted for parsing.
lsjson List directories and objects in the path in JSON format.
lsl List the objects in path with modification time, size and path.
md5sum Produces an md5sum file for all the objects in the path.
mkdir Make the path if it doesn't already exist.
mount Mount the remote as file system on a mountpoint.
move Move files from source to dest.
moveto Move file or directory from source to dest.
ncdu Explore a remote with a text based user interface.
obscure Obscure password for use in the rclone config file.
purge Remove the path and all of its contents.
rc Run a command against a running rclone.
rcat Copies standard input to file on remote.
rcd Run rclone listening to remote control commands only.
rmdir Remove the path if empty.
rmdirs Remove empty directories under the path.
serve Serve a remote over a protocol.
settier Changes storage class/tier of objects in remote.
sha1sum Produces an sha1sum file for all the objects in the path.
size Prints the total size and number of objects in remote:path.
sync Make source and dest identical, modifying destination only.
touch Create new file or change file modification time.
tree List the contents of the remote in a tree like fashion.
version Show the version number.
Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
- 01
- 旧电脑安装windows11最简单的方法-绿色又健康,附激活脚本11-08
- 02
- 小白入门级NAS首选,开箱即用,不折腾,打造你的家庭影院09-29
- 03
- 工信部出手,查一下你的手机号都注册了哪些网络账号09-26