Object Management for Managing your Objects — Listing, Moving, Deleting and More!

Jenny Brown
Oct 25 · 6 min read

We’ve gone over uploading, we’ve gone over downloading. We’ve even discussed the various types of access policy you can assign to your various assets. After all of that, there are plenty of places left for us to go and learn even more, but today we’re going to focus on how you track, manage, and work with your objects.

What do we have here? Listing Objects

Anytime you want to do something with the objects in your bucket, it helps to know what’s there. Starting with a list will get you the inventory you need of all those data objects you’ve got, unless you’ve somehow memorized them. In that case, skip ahead with your mental map of objects!

For the rest of us, we’ll time-travel back to an earlier blog about getting data in to Google Cloud Storage…You may remember there are two main options for interacting with your Cloud Storage: Command Line GSutil, and the Cloud Console. These two will be our go-to’s for a while, so feel free to get familiar with them. I’ll give the highlights below, but as usual, feel free to check out this article for some other specifics on listing objects.

List in GSutil

When listing the contents of a bucket with the GSutil, you’ll get a nice structured response, making it easy to see what you’ve got and where.

List in the Cloud Console

And, of course, the Cloud Console offers a convenient visual interface, with drop-downs and buttons for looking at your files and directories.

Simply open the Cloud Storage Browser in the Google Cloud Platform Console, and go to the bucket list.

Select the bucket whose contents you’d like to see listed, by clicking on the linked name of that bucket in the Name column.

This will take you to the Bucket details page, where you’ll be able to view a list of the objects in that bucket.

OR you can use the filter by prefix field to narrow down the results based on a prefix you specify.

Making Changes — Renaming, Copying, and Moving

Now that you know what’s in your bucket, let’s talk about some of the changes you can make to those objects. Maybe you’ve rebranded and need to adjust all of the file names in a certain directory. Or perhaps you’ve discovered out of date policy, and need to move the associated paperwork, and archive the source materials by getting them into a different folder.

All of these things are possible, and we’ll break it down below.

But first, a quick note: When renaming or moving objects, make sure you double check the storage class — changing objects from Nearline or Coldline storage could result in an early deletion charge. More on changing the storage class of an object here, and the various ways to rename, copy, and move an object in this article.

Renaming

Renaming an existing object in one of your Cloud Storage buckets by using the mv command. Renaming (and copying, which we’ll get to in a bit) objects works by copying each object to a new object with the desired name, and then deleting the original. Check out this documentation on the mv command for examples and details.

Renaming in GSutil

To rename an object using GSutil, use the gsutil mv command:

Renaming in the Cloud Console

In the console, navigate to the object listing for the bucket of your choice (following the same steps as above). Once you’re in the specified bucket, you can use the handy three-dot menu next to the object to be renamed, and click “rename.”

From there, simply follow the prompts in the overlay window that appears.

Copying

Use the following guidelines to copy an object, whether you’re making another instance of it in the current bucket, or adding an instance of it in another bucket.

Copying in GSutil

Copying with GSutil requires the gsutil cp command:

Copying in the Cloud Console

In the console, navigate to your bucket, and then object listing. Select the three dot menu on the object you’d like to copy, and click “copy.”

In the overlay window, click “Browse”:

In the browsing overlay window, select a destination and name for the copied object:

After selecting the destination and name, then click “copy” in the original overlay window to complete the process.

Moving

Moving objects is another process that uses the mv command. Please note that while moving an object appears to be a unique operation, it’s always a copy operation followed by a delete operation of the original object. Depending on which tool you use to complete a move, this may or may not be apparent. In addition to working on single objects, you can also move multiple objects with a common prefix using the gsutil mv command.

Moving in GSutil

Moving objects with GSutil uses the gsutil mv command:

Moving in the Cloud Console

To move an object out of its current bucket and into a new or different bucket in the Cloud Console, navigate to the bucket of your choice and its object list.

Select the three dot menu next to the object you’d like to move, and click “move”

In the overlay window that appears, click “browse” to select the destination for the object you’re moving

From there, simply select the destination, and click “move” to complete.

Deleting

For a more permanent change, you can always delete an object; removing it from the bucket, and effectively from your Cloud Storage. Object deletion can’t be undone, and will also trigger any appropriate early deletion policies depending on your storage class, so check out this article, and “Deleting Data Best Practices” to save yourself from potential heartache!

Deleting in GSutil

Deleting in the Cloud Console

To delete an object in the console, navigate to the list of buckets, and click on the name of the bucket that contains the object to be deleted.

Once you’re in the bucket details, select the object to be deleted by clicking the checkbox to the left of the object name.

Click the “delete” button, and then, once you’re certain, “delete” again in the pop up window that appears

After your second “delete” click, that object is history. If needed, you can use these same steps to delete folders in a bucket as well.

That’s more than enough for one blog, but if you need any further help, check out the linked articles for some straightforward advice (or alternative ways to accomplish your goals), and stay tuned for the next blog about improving performance!

Jenny Brown

Written by

Google Cloud Developer Advocate, Thinker, Feeler, Adventurer, Surfer, Burner. Opinions are my own, but I’m happy to share.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade