8

I have uploaded several files into the same folder on Google Cloud Storage using the Google Cloud Console. I would now like to move several of the files to a newly created folder in Google Cloud Storage and I cannot see how to do that via the Google Cloud Console. I found instructions to move the files via command prompt instructions on gsutil. However, I am not comfortable with command line interfaces and have not been able to get gsutil to work on my machine.

Is there a way to move files in Google Cloud Storage from one folder to another via the Google Cloud Console?

Misha Brukman
  • 10,866
  • 4
  • 54
  • 71
Kelly
  • 653
  • 1
  • 6
  • 5
  • 1
    As a side question, what problems are you running into getting gsutil working on your machine? The command line for the operation you'd like to do is fairly simple: gsutil mv gs://bucket-name/source-folder gs://bucket-name/destination-folder-name – Travis Hobrla Aug 19 '14 at 22:13
  • Thank you for the follow up. Most of my problems are based in my ignorance of command line programing. I am based on Mac OS. I followed the instructions to install gsutil in my home directory. The first few commands (install, add to path, restart) seemed to work. When I restarted the shell and attempted an update and/or config command i receive a "command not found" message. Therefore, I have not been able to authenticate or do anything else. – Kelly Aug 19 '14 at 23:18
  • Command line does take some getting used to. If you can locate where the gsutil install directory is with respect to your home directory, in a new terminal you should be able to run '~/thatdirectory/gsutil your-command' from your shell. – Travis Hobrla Aug 20 '14 at 16:26

3 Answers3

6

Update: Google Cloud Shell provides a terminal within the Google Cloud Console site without having to manually create VMs; it comes with gsutil and Google Cloud SDK pre-installed and pre-authenticated.


Prior answer: If you're having issues installing gsutil on your computer, consider the following approach:

  1. Spin up an f1-micro instance with the Google-provided Debian image which will have gsutil preinstalled.

  2. Use the SSH button to connect to it using the browser interface (you can also use gcutil or gcloud commands, if you have those installed and available).

  3. Run gcloud auth login --no-launch-browser within the instance. It will give you a URL to open with your browser. Once you open it, grant the OAuth permissions, and it will display a code. Paste that code back into the command-line window where you ran the command so that it gets the authentication token.

  4. Run the gsutil mv command, as suggested by Travis Hobrla:

    gsutil mv gs://bucket/source-object gs://bucket/dest-object

  5. Once you're done with gsutil, delete the instance by clicking on the Delete button at the top of the VM instance detail page. Make sure that the box marked "Delete boot disk when instance is deleted" on the same VM instance page is checked, so that you don't leave an orphaned disk around, which you will be charged for.

    You can also browse your persistent disks on the "Disks" tab right below the "VM instances" tab, and delete disks manually there, or make sure there aren't an orphaned disks in the future.

Given the current price of $0.013/hr for an f1-micro instance, this should cost you less than a penny to do this, as you'll only be charged while the instance exists.

Misha Brukman
  • 10,866
  • 4
  • 54
  • 71
  • Thank you very much for your willingness to help someone who is obviously in over my depth... I attempted to follow your instructions and receives the following error message: kelly_kellydmyers_com@gsutil:~$ gsutil mv gs://diabetes-2014/qd81_diab_px_fact_201402.txt.gz gs://diabetes-201 4/px Copying gs://diabetes-2014/qd81_diab_px_fact_201402.txt.gz [Content-Type=application/x-gzip]... AccessDeniedException: 403 Insufficient Permission kelly_kellydmyers_com@gsutil:~$ – Kelly Aug 20 '14 at 16:49
  • @Kelly My apologies. First, you have to run `gcloud auth login` in the instance and follow its instructions. I have just tried this out to confirm and it worked for me. I will update the directions above with more details. – Misha Brukman Aug 20 '14 at 21:44
  • Success! Thank you very much. I really appreciate the help. One last remedial question, DO I simply click on the "Delete" button in the instance that i created on the google developers console to stop the session? Thanks – Kelly Aug 20 '14 at 22:19
  • @Kelly Yes, clicking the `Delete` button will do. But before you do that, make sure that the box marked "Delete boot disk when instance is deleted" on the same VM instance page is checked, so that you don't leave an orphaned disk around (which you will be charged for). You can also browse your persistent disks on the "Disks" tab right below the "VM instances" tab, and delete disks manually there, or make sure there aren't an orphaned disks in the future. – Misha Brukman Aug 21 '14 at 14:19
  • Great. Thanks. I was not sure what to do about the Disk. – Kelly Aug 21 '14 at 14:48
2

There is not currently a way to do this via the Google Cloud Console.

Because folders in Google Cloud Storage are really just placeholder objects in a flat namespace, it's not possible to do an atomic move or rename of a folder, which is why this scenario is more complex than doing a folder move in a local filesystem (with a hierarchical namespace). That's why a more complex tool like gsutil is needed.

Misha Brukman
  • 10,866
  • 4
  • 54
  • 71
Travis Hobrla
  • 4,555
  • 19
  • 19
0

Google Cloud Storage now has the functionality to move files from one folder/bucket to another using Cloud Console. To do this, simply select the file(s), click on the 3 vertical dots to get the option of move. Select the target folder/bucket to move the file.

Cloud Storage Copy

Imran Khan
  • 31
  • 2