Google Storage Team wrote:
> Hi,
>
> > where I've created the "directory" folder in my bucket using the online
> browser.
>
> The browser UI is creating an object named "directory" and simulating
> folder behavior (using the slash character in object names as a delimiter)
> but your "directory" is really a flat object, not a folder. That's why when
> you try to copy multiple files to that object, you get this error:
>
> "CommandException: Destination URI must name a bucket or directory for the
> multiple source form of the cp command."
>
> As with local shell commands, the target of a multiple source copy must be
> a container, i.e., a directory/folder in your local file system or a bucket
> in the Google Cloud Storage world.
I've tried again without first creating the directory in the browser,
but the error still occurs.
I understand that the storage file hierarchy is just conceptual, but I
think that the multiple-file "gsutil cp" command should work with
destination paths by treating the destination as a directory name (key
prefix), only giving an error if the destination name exists (as a
file/key).
>
> Are you running on Linux (or some variant of Unix)? If so, you could use
> find and xargs to filter out your .svn files, like this:
>
> find . -not -name .svn -type f | xargs -I '{}' gsutil cp '{}' gs://bucket
>
>
> This is inefficient for a large number of files because it invokes gsutil
> once for every file. A better approach for a large number of files would be
> to write a simple wrapper shell script that runs gsutil with all supplied
> source arguments, like this:
>
> #!/bin/sh
> # gsutil_wrapper.sh - bundles command line args into one gsutil copy
> command (using -m for parallelism)
>
> gsutil -m cp $* gs://bucket
>
>
> With such a script, the previous find/xargs pipeline could be rewritten in
> a simpler and more efficient way:
>
> find . -not -name .svn -type f | xargs gsutil_wrapper.sh
Great suggestions.
I found that find can be made to exclude all hidden files via
find . -not -path '*/.*'
But both copy methods given will create all files in the root of the
bucket, when I want to re-create the directory structure.
Your first method can however be made to work:
find . -not -path '*/.*' -type f -printf '%P\n' | xargs -I '{}' gsutil
cp '{}' gs://bucket/'{}'
But I don't see a way of making the parallel version work.
> Hope that helps,
Yes. Thank you Marc for your detailed reply.