Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

azure - Azcopy - Copy only files without folders

As the title suggests I am trying to copy all files with a specific extension, within a folder structure, to blob storage without recreating the local folder structure;

This works fine when I run the following;

azcopy cp 'H:folder1folder2*.txt' 'https://storage.blob.core.windows.net/folderA/folderB/?saskey'

This copies all *.txt files to /folderB

I have tried many variations of the following;

azcopy.exe cp 'H:folder1**' 'https://storage.blob.core.windows.net/folderA/folderB/?saskey' --recursive --include-pattern '*.txt'

Regardless of what I try I end up with the following;

/folderA/folderB
            /folder1/fileA.txt
            /folder2/fileB.txt

I was under the impress that is what the "--recursive" switch was for, but what I am doing is either not supported or my syntax is wrong.

I have read through this; https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-files#use-wildcard-characters

I could probably script it with something similar to this; AzCopy - Wildcards In Middle Of Pattern? But was hoping this was built-in functionality

question from:https://stackoverflow.com/questions/65849113/azcopy-copy-only-files-without-folders

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

What you are looking for is not supported. Using --recursive would result in the subdirectory structure of the source retained in the destination. I am not aware of any flag to prevent that.

Actually that helps to avoid conflict. Let's say for example, you have files /folder1/fileA.txt and /folder2/fileA.txt in source. If you try to copy flat in destination (without subpath), that would have caused conflict since both file names are fileA.txt.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...