Lsjson and --filter

What is the problem you are having with rclone?

I would like to be able to filter lsjson --recursive the same as ls.

Currently, lsjson --recursive --filter "some filter" --filter "some other filter" includes all filtered files AND their parent folders.

Can --files-only be encoded into a filter?

filtering with ls vs lsjson --recursive find different files / folders.

The --files-only flag does what I need, but since this is all running inside a python framework, the fewer external dependencies / inputs the better.

I would hope that the filters on lsjson --recursive would obey those filters and only match exactly the files and not their containing folders.

Is there a way to achieve this without --files-only

What is your rclone version (output from rclone version)

rclone v1.54.0

  • os/arch: linux/amd64
  • go version: go1.15.7

Which OS you are using and how many bits (eg Windows 7, 64 bit)

ubuntu 20.04

Which cloud storage system are you using? (eg Google Drive)

owncloud / local alias

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Other than the ls vs lsjson --recursive, the commands are the same, however, the lsjson --recursive returns all the parent folders as well.

Since I am reading the output of this into a python parser, I need the lsjson command to return consistent results.

example = ls
rclone --config /home/speters/.config/rclone/rclone.conf lsjson --filter '+ *.tga' --filter '- *' studio:/__tests__/rclone --dump filters

output:

--- start filters ---
--- File filter rules ---
+ (^|/)[^/]*\.tga$
- (^|/)[^/]*$
--- Directory filter rules ---
+ ^.*$
- ^.*$
--- end filters ---
  3145772 EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_col.tga
  3145772 EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_normal.tga
  3145772 EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_roughness.tga
  3145772 EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_spec.tga

vs

example lsjson --recursive
rclone --config /home/speters/.config/rclone/rclone.conf lsjson --filter '+ *.tga' --filter '- *' --recursive studio:/__tests__/rclone --dump filters

output

--- start filters ---
--- File filter rules ---
+ (^|/)[^/]*\.tga$
- (^|/)[^/]*$
--- Directory filter rules ---
+ ^.*$
- ^.*$
--- end filters ---
[
{"Path":"EyFabChgFcvdtpr7ysmqHy","Name":"EyFabChgFcvdtpr7ysmqHy","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-23T18:58:21Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.1","Name":"0.0.1","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-17T00:20:45Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.2","Name":"0.0.2","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-17T00:20:48Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.3","Name":"0.0.3","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-18T20:51:18Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4","Name":"0.0.4","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-23T18:58:21Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/model","Name":"model","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-23T18:58:22Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture","Name":"texture","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-23T18:58:24Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.3/remote_subir","Name":"remote_subir","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-18T20:51:18Z","IsDir":true},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_col.tga","Name":"temp_texture_col.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:37:04Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_normal.tga","Name":"temp_texture_normal.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:39:00Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_roughness.tga","Name":"temp_texture_roughness.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:37:46Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_spec.tga","Name":"temp_texture_spec.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:38:18Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.3/remote_subir/sub_sub","Name":"sub_sub","Size":-1,"MimeType":"inode/directory","ModTime":"2021-03-18T20:51:18Z","IsDir":true}
]

vs
lsjson --resursive --files-only

rclone --config /home/speters/.config/rclone/rclone.conf lsjson --filter '+ *.tga' --filter '- *' --recursive --files-only studio:/__tests__/rclone --dump filters

output:

--- start filters ---
--- File filter rules ---
+ (^|/)[^/]*\.tga$
- (^|/)[^/]*$
--- Directory filter rules ---
+ ^.*$
- ^.*$
--- end filters ---
[
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_col.tga","Name":"temp_texture_col.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:37:04Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_normal.tga","Name":"temp_texture_normal.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:39:00Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_roughness.tga","Name":"temp_texture_roughness.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:37:46Z","IsDir":false},
{"Path":"EyFabChgFcvdtpr7ysmqHy/0.0.4/texture/temp_texture_spec.tga","Name":"temp_texture_spec.tga","Size":3145772,"MimeType":"application/octet-stream","ModTime":"2021-01-21T16:38:18Z","IsDir":false}
]

The rclone config contents with secrets removed.

Paste config here

A log from the command with the -vv flag

Paste  log here

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.