-1

Can't find any reference to this. Seems like a basic capability of any file storage in general.

nsof
  • 2,299
  • 1
  • 20
  • 28

3 Answers3

2

Alternative is using the command line for this(gcloud/gsutil)

Assuming you have gcloud already installed... do next:

Using terminal(check/set) GCP project you are logged in:

$> gcloud config list - to check if you are using the proper GCP project.

$> gcloud config set project <your_project_id> - to set required project

Get the total bucket/folder size:

gsutil du -sah gs://bucket_name/folder1

List objects sorted by date ascending:

gsutil ls -l gs://bucket_name/folder1/folder2 | sort -k 2

List objects sorted by size descending:

gsutil du -ah gs://bucket_name/folder1/folder2/* | sort -k 2

List unique objects by prefix(for example object name pattern: twitter_2020-09-03-03-01-10.csv, facebook_2020-09-03-03-01-11.csv):

gsutil ls gs://bucket_name/folder_name | sed 's/_.*//' | uniq

Here (in the last example) if you have multiple twitter, facebook files in that folder the result will be:

gs://bucket_name/folder_name/twitter
gs://bucket_name/folder_name/facebook
2

Google Cloud added the ability to do this, but it's a bit hidden. You want to click on the dropdown right above the directory listing where it says Filter by name prefix only and then you can select Sort and filter. After that you should be able to click on a column to sort by that column.

Google Cloud warns that this will make the UI slower.

Stephen
  • 8,508
  • 12
  • 56
  • 96
1

Currently, there is no way to sort the files or folders inside a bucket on the Cloud Console.

You can always do by coding a sorting routine:

// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');

// Your Google Cloud Platform project ID
const projectId = 'YOUR PROJECT';

// Creates a client
const storage = new Storage({
  projectId: projectId,
});

// The name for the new bucket
const bucketName = 'YOUR-BUCKET';
const bucket = storage.bucket(bucketName);
bucket.getFiles(null, (err,data) => {
    data.sort((a, b) => {
        if (a.metadata.updated > b.metadata.updated) {
            return 1;
        }
        if (a.metadata.updated < b.metadata.updated) {
            return -1;
        }
        return 0;
    });
    for (file of data) {
        console.log(` ${file.metadata.name} - ${file.metadata.updated}`);
    }
});

There is a Feature request but seems that is not updated.

https://issuetracker.google.com/issues/119209458

Mario
  • 406
  • 2
  • 6