rclone/docs/content/commands/rclone_lsf.md

158 lines
5.2 KiB
Markdown
Raw Normal View History

2018-03-19 11:06:13 +01:00
---
title: "rclone lsf"
2021-02-02 14:42:35 +01:00
description: "List directories and objects in remote:path formatted for parsing."
2018-03-19 11:06:13 +01:00
slug: rclone_lsf
url: /commands/rclone_lsf/
# autogenerated - DO NOT EDIT, instead edit the source code in cmd/lsf/ and as part of making a release run "make commanddocs"
2018-03-19 11:06:13 +01:00
---
# rclone lsf
2018-03-19 11:06:13 +01:00
2021-02-02 14:42:35 +01:00
List directories and objects in remote:path formatted for parsing.
2018-03-19 11:06:13 +01:00
## Synopsis
2018-03-19 11:06:13 +01:00
List the contents of the source path (directories and objects) to
standard output in a form which is easy to parse by scripts. By
default this will just be the names of the objects and directories,
one per line. The directories will have a / suffix.
2018-04-28 12:46:27 +02:00
Eg
$ rclone lsf swift:bucket
bevajer5jef
canole
diwogej7
ferejej3gux/
fubuwic
2018-03-19 11:06:13 +01:00
Use the --format option to control what gets listed. By default this
is just the path, but you can use these parameters to control the
output:
p - path
s - size
t - modification time
h - hash
2019-04-13 12:01:58 +02:00
i - ID of object
o - Original ID of underlying object
2018-06-16 19:21:09 +02:00
m - MimeType of object if known
2019-04-13 12:01:58 +02:00
e - encrypted name
2021-02-02 14:42:35 +01:00
T - tier of storage if known, e.g. "Hot" or "Cool"
2018-03-19 11:06:13 +01:00
So if you wanted the path, size and modification time, you would use
--format "pst", or maybe --format "tsp" to put the path last.
2018-04-28 12:46:27 +02:00
Eg
$ rclone lsf --format "tsp" swift:bucket
2016-06-25 18:55:41;60295;bevajer5jef
2016-06-25 18:55:43;90613;canole
2016-06-25 18:55:43;94467;diwogej7
2018-04-26 08:50:45;0;ferejej3gux/
2016-06-25 18:55:40;37600;fubuwic
2018-03-19 11:06:13 +01:00
If you specify "h" in the format you will get the MD5 hash by default,
use the "--hash" flag to change which hash you want. Note that this
can be returned as an empty string if it isn't available on the object
(and for directories), "ERROR" if there was an error reading it from
the object and "UNSUPPORTED" if that object does not support that hash
type.
2022-03-18 13:29:54 +01:00
For example, to emulate the md5sum command you can use
2018-03-19 11:06:13 +01:00
rclone lsf -R --hash MD5 --format hp --separator " " --files-only .
2018-04-28 12:46:27 +02:00
Eg
2022-03-18 13:29:54 +01:00
$ rclone lsf -R --hash MD5 --format hp --separator " " --files-only swift:bucket
2018-04-28 12:46:27 +02:00
7908e352297f0f530b84a756f188baa3 bevajer5jef
cd65ac234e6fea5925974a51cdd865cc canole
03b5341b4f234b9d984d03ad076bae91 diwogej7
8fd37c3810dd660778137ac3a66cc06d fubuwic
99713e14a4c4ff553acaf1930fad985b gixacuh7ku
2018-03-19 11:06:13 +01:00
(Though "rclone md5sum ." is an easier way of typing this.)
By default the separator is ";" this can be changed with the
--separator flag. Note that separators aren't escaped in the path so
putting it last is a good strategy.
2018-04-28 12:46:27 +02:00
Eg
$ rclone lsf --separator "," --format "tshp" swift:bucket
2016-06-25 18:55:41,60295,7908e352297f0f530b84a756f188baa3,bevajer5jef
2016-06-25 18:55:43,90613,cd65ac234e6fea5925974a51cdd865cc,canole
2016-06-25 18:55:43,94467,03b5341b4f234b9d984d03ad076bae91,diwogej7
2018-04-26 08:52:53,0,,ferejej3gux/
2016-06-25 18:55:40,37600,8fd37c3810dd660778137ac3a66cc06d,fubuwic
2018-06-16 19:21:09 +02:00
You can output in CSV standard format. This will escape things in "
if they contain ,
Eg
$ rclone lsf --csv --files-only --format ps remote:path
test.log,22355
test.sh,449
"this file contains a comma, in the file name.txt",6
Note that the --absolute parameter is useful for making lists of files
to pass to an rclone copy with the --files-from-raw flag.
2018-06-16 19:21:09 +02:00
2022-03-18 13:29:54 +01:00
For example, to find all the files modified within one day and copy
2018-06-16 19:21:09 +02:00
those only (without traversing the whole directory structure):
rclone lsf --absolute --files-only --max-age 1d /path/to/local > new_files
rclone copy --files-from-raw new_files /path/to/local remote:path
2018-06-16 19:21:09 +02:00
2018-04-28 12:46:27 +02:00
Any of the filtering options can be applied to this command.
2018-03-19 11:06:13 +01:00
There are several related list commands
* `ls` to list size and path of objects only
* `lsl` to list modification time, size and path of objects only
* `lsd` to list directories only
* `lsf` to list objects and directories in easy to parse format
* `lsjson` to list objects and directories in JSON format
2022-03-18 13:29:54 +01:00
`ls`,`lsl`,`lsd` are designed to be human-readable.
`lsf` is designed to be human and machine-readable.
`lsjson` is designed to be machine-readable.
2018-03-19 11:06:13 +01:00
2021-02-02 14:42:35 +01:00
Note that `ls` and `lsl` recurse by default - use `--max-depth 1` to stop the recursion.
2018-04-28 12:46:27 +02:00
2021-02-02 14:42:35 +01:00
The other list commands `lsd`,`lsf`,`lsjson` do not recurse by default - use `-R` to make them recurse.
2018-03-19 11:06:13 +01:00
2022-03-18 13:29:54 +01:00
Listing a non-existent directory will produce an error except for
2021-02-02 14:42:35 +01:00
remotes which can't have empty directories (e.g. s3, swift, or gcs -
2022-03-18 13:29:54 +01:00
the bucket-based remotes).
2018-03-19 11:06:13 +01:00
```
rclone lsf remote:path [flags]
```
## Options
2018-03-19 11:06:13 +01:00
```
2021-11-01 16:42:05 +01:00
--absolute Put a leading / in front of path names
--csv Output in CSV format
-d, --dir-slash Append a slash to directory names (default true)
--dirs-only Only list directories
--files-only Only list files
2018-03-19 11:06:13 +01:00
-F, --format string Output format - see help for details (default "p")
2021-06-08 17:57:04 +02:00
--hash h Use this hash when h is used in the format MD5|SHA-1|DropboxHash (default "md5")
2018-03-19 11:06:13 +01:00
-h, --help help for lsf
2021-11-01 16:42:05 +01:00
-R, --recursive Recurse into the listing
-s, --separator string Separator for the items in the format (default ";")
2018-03-19 11:06:13 +01:00
```
See the [global flags page](/flags/) for global options not listed here.
## SEE ALSO
2018-03-19 11:06:13 +01:00
2018-10-15 12:03:08 +02:00
* [rclone](/commands/rclone/) - Show help for rclone commands, flags and backends.
2018-03-19 11:06:13 +01:00