Tree command output with folders sizes

I'm trying to use tree command to get a list of folders with their sizes, something similar to ncdu output, but I think I'm missing something...

When I run:

rclone tree backend: --size

I get:

[14235615276]  /
└── [14235615276]  folder 1
    ├── [   15146768]  folder 1.1
    │   └── ├── [     849466]  file 1
    │       ├── [     393837]  file 2
    │       ├── ...
    │       └── [      80711]  file N
    ├── [       1384]  folder 1.2

But when I run:

rclone tree backend: --size --dirs-only

I get:

[          0]  /
└── [          0]  folder 1
    ├── [          0]  folder 1.1
    ├── [          0]  folder 1.2

I think it's because Rclone isn't parsing the files in the folders.

How do I get something like this? :point_down:

[14235615276]  /
└── [14235615276]  folder 1
    ├── [   15146768]  folder 1.1
    ├── [       1384]  folder 1.2


No idea? :cry: :upside_down_face:

I doubt there is an easy way :sob:

The rclone tree command is based on a8m/tree, that implements the tree command in Go.

The original tree command:

tree  ./ -s -d

will just show the size of the directory blocks (E.g. 512 bytes for each folder), so I would say that a8m/tree is correctly mimicing the tree command.

My best idea is to use a color hack :nerd_face: and some scripting, this illustrates the concept:

rclone tree backend: --size --color | grep "1;34m"
1 Like

Interesting, I hadn't thought of a "color" solution, thanks! But even with this color based solution the generated file would still be very large (because it would list the files as well).

I actually already had a plan b, but I hoped there would be a simpler solution.

I'll probably have to create a script that does something like:

  • run a lsd and point to a controlled output;
  • run a size for each of the above output lines, generating an output "report".

I guess you are asking on Windows? On Linux, you can mount it and just du -sh * in a directory and that shows the size for each directory.

Sorry for not having informed in the original post...

I'm running on Windows but the backend in question is on Google Drive.

there is a way to run a linux commands on a rclone mount running on windows.
this is not all the steps needed, but enough to get an idea

  1. on windows, create a rclone mount such as
    rclone mount remote: b:\mount\rclone\remote
  2. net share b:\mount\rclone with a sharename of remote
  3. run a command such as
C:\data>wsl du -sh /mnt/remote/files
2.2M    /mnt/remote/files

I see you are on Windows, so this is the color hack for PowerShell:

rclone tree backend: --size --color | Select-String "1;34m" | ForEach-Object {$_ -replace 'Γöé|Γö£|Γöö','|' -replace 'ΓöÇ','-'}

It only shows the folders and takes less than a minute on my GoogleDrive with app. 50.000 files.

This is faster than measuring the folders individually due to less overhead to start rclone, establish connection, login, etc. It may be even faster with --fast-list.

If you like coding (data parsing and accumulation), then you may want to consider lsf or lsjson with --recursive - again you will get all the data in a single Go - no pun intended :grinning_face_with_smiling_eyes:

1 Like

use rclone ncdu remote:

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