Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



mv - Move/rename objects and/or subdirectories

mv - Move/rename objects and/or subdirectories

Synopsis

gsutil mv [-p] src_url dst_url gsutil mv [-p] url... dst_url

Description

The gsutil mv command allows you to move data between your local file system and the cloud, move data within the cloud, and move data between cloud storage providers. For example, to move all objects from a bucket to a local directory you could use:

gsutil mv gs://my_bucket dir

Similarly, to move all objects from a local directory to a bucket you could use:

gsutil mv ./dir gs://my_bucket

Renaming Bucket Subdirectories

You can use the gsutil mv command to rename subdirectories. For example, the command:

gsutil mv gs://my_bucket/olddir gs://my_bucket/newdir

would rename all objects and subdirectories under gs://my_bucket/olddir to be under gs://my_bucket/newdir, otherwise preserving the subdirectory structure.

If you do a rename as specified above and you want to preserve ACLs, you should use the -p option (see OPTIONS).

Note that when using mv to rename bucket subdirectories you cannot specify the source URL using wildcards. You need to spell out the complete name:

gsutil mv gs://my_bucket/olddir gs://my_bucket/newdir

If you have a large number of files to move you might want to use the gsutil -m option, to perform a multi-threaded/multi-processing move:

gsutil -m mv gs://my_bucket/olddir gs://my_bucket/newdir

Non-atomic Operation

Unlike the case with many file systems, the gsutil mv command does not perform a single atomic operation. Rather, it performs a copy from source to destination followed by removing the source for each object.

Options

All options that are available for the gsutil cp command are also available for the gsutil mv command (except for the -R flag, which is implied by the gsutil mv command). Please see the OPTIONS sections of gsutil help cp for more information.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.