ó ôBQc@s@ddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z dd l mZdd l mZddl mZddl mZddl mZddl mZddlmZdZdefd„ƒYZdS(iÿÿÿÿ(tCommand(t COMMAND_NAME(tCOMMAND_NAME_ALIASES(tCONFIG_REQUIRED(t FILE_URIS_OK(tMAX_ARGS(tMIN_ARGS(tPROVIDER_URIS_OK(tSUPPORTED_SUB_ARGS(tURIS_START_ARG(tCommandException(t HELP_NAME(tHELP_NAME_ALIASES(tHELP_ONE_LINE_SUMMARY(t HELP_TEXT(tHelpType(t HELP_TYPE(tNO_MAXs SYNOPSIS gsutil mv [-p] src_uri dst_uri - or - gsutil mv [-p] uri... dst_uri 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 URI 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 -p Causes ACL to be preserved when moving in the cloud. Note that this option has performance and cost implications, because it is essentially performing three requests (getacl, cp, setacl). (The performance issue can be mitigated to some degree by using gsutil -m cp to cause multi-threaded/multi-processing copying.) t MvCommandcBs—eZdZi de6dddge6de6ee6de6e e 6e e 6de 6e e6Zide6ddge6eje6de6ee6Zd „ZRS( sŸImplementation of gsutil mv command. Note that there is no atomic rename operation - this command is simply a shorthand for 'cp' followed by 'rm'. tmvtmovetrentrenameitpvis)Move/rename objects and/or subdirectoriescCs®xP|jdd!D]>}|jj|ƒjƒrtd||jdfƒ‚qqWdg}|jru|jdƒn|j|jƒ|j j d||j |j |j ƒdS(Niiÿÿÿÿs”You cannot move a source bucket using the mv command. If you meant to move all objects in the bucket, you can use a command like: gsutil mv %s/* %ss-Ms-Rtcp(targst suri_buildert StorageUrit names_bucketR trecursion_requestedtappendtextendt unparsed_argstcommand_runnertRunNamedCommandtheaderstdebugtparallel_operations(tselft arg_to_checkR ((s//tmp/tmp.yUYbTOKr8o/gsutil/gslib/commands/mv.pyt RunCommand‡s  (t__name__t __module__t__doc__RRRRRRtTrueRtFalseRR Rt command_specR R Rt COMMAND_HELPRR t_detailed_help_textRt help_specR((((s//tmp/tmp.yUYbTOKr8o/gsutil/gslib/commands/mv.pyR^s$    N(t gslib.commandRRRRRRRRRR tgslib.exceptionR tgslib.help_providerR R R RRRt gslib.utilRR0R(((s//tmp/tmp.yUYbTOKr8o/gsutil/gslib/commands/mv.pyts&;