krosbonz
krosbonz

Reputation: 21

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:\folder1\folder2\*.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://learn.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

Upvotes: 2

Views: 4018

Answers (1)

krishg
krishg

Reputation: 6508

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.

Upvotes: 1

Related Questions