"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
lsf: add --files-only and --dirs-only flags
Nick Craig-Wood0eba37d8f35b
diff --git a/cmd/lsf/lsf.go b/cmd/lsf/lsf.goindex 0f552e3cc..9f549cdc5 100644--- a/cmd/lsf/lsf.go+++ b/cmd/lsf/lsf.go@@ -18,6 +18,8 @@ var (dirSlash boolrecurse boolhashType = fs.HashMD5+ filesOnly bool+ dirsOnly bool)func init() {@@ -27,6 +29,8 @@ func init() {flags.StringVarP(&separator, "separator", "s", ";", "Separator for the items in the format.")flags.BoolVarP(&dirSlash, "dir-slash", "d", true, "Append a slash to directory names.")flags.VarP(&hashType, "hash", "", "Use this hash when `h` is used in the format MD5|SHA-1|DropboxHash")+ flags.BoolVarP(&filesOnly, "files-only", "", false, "Only list files.")+ flags.BoolVarP(&dirsOnly, "dirs-only", "", false, "Only list directories.")commandDefintion.Flags().BoolVarP(&recurse, "recursive", "R", false, "Recurse into the listing.")}@@ -58,6 +62,12 @@ can be returned as an empty string if it isn't available on the objectthe object and "UNSUPPORTED" if that object does not support that hashtype.+For example to emulate the md5sum command you can use++ rclone lsf -R --hash MD5 --format hp --separator " " --files-only .++(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 soputting it last is a good strategy.@@ -100,6 +110,16 @@ func Lsf(fsrc fs.Fs, out io.Writer) error {return nil}for _, entry := range entries {+ _, isDir := entry.(fs.Directory)+ if isDir {+ if filesOnly {+ continue+ }+ } else {+ if dirsOnly {+ continue+ }+ }fmt.Fprintln(out, fs.ListFormatted(&entry, &list))}return nildiff --git a/cmd/lsf/lsf_test.go b/cmd/lsf/lsf_test.goindex 7f3fec1dc..55d60515c 100644--- a/cmd/lsf/lsf_test.go+++ b/cmd/lsf/lsf_test.go@@ -112,6 +112,26 @@ subdir;subdir`, buf.String())+ buf = new(bytes.Buffer)+ format = "p"+ filesOnly = true+ err = Lsf(f, buf)+ require.NoError(t, err)+ assert.Equal(t, `file1+file2+file3+`, buf.String())+ filesOnly = false++ buf = new(bytes.Buffer)+ format = "p"+ dirsOnly = true+ err = Lsf(f, buf)+ require.NoError(t, err)+ assert.Equal(t, `subdir+`, buf.String())+ dirsOnly = false+buf = new(bytes.Buffer)format = "t"err = Lsf(f, buf)