Is it possible to use regular expression in azcopy?

2.2k Views Asked by At

I am new to azure. I am have a container and in the container i have multiple directory and sub directory.

I have multiple files in the sub directory. I need to download the latest file from the sub directory. The file name will be "20201126_filename"

I am planning to use regular expression to download the latest file. Regular expression for the date

As of now i use the command.

azcopy cp "https://storageforecast.blob.core.windows.net/utopus/pollo/pollo1/pollo2/20201126_filename?si=plus&sv=201q7ZQ%2BMAVZhkpCwrXs1ns3fzpzNm0QI%3D" "E:\111" --recursive

Utopus- container pollo - directory pollo1- subdirectory pollo2-sub directory

Could you pls help me!!!

2

There are 2 best solutions below

1
On

No, there is no way to use regular expression in azcopy.

Have a check of this azcopy offcial doc and check the options:

https://learn.microsoft.com/en-us/azure/storage/common/storage-ref-azcopy-copy#options

You can use --include-after to copy the latest blobs.:)

0
On

azcopy V10.12.0 supports regex

https://github.com/Azure/azure-storage-azcopy/releases/tag/v10.12.0

Added support for include and exclude regex flags, which allow pattern matching on the entire paths.

From the azcopy sync documentation:

--exclude-regex string Exclude the relative path of the files that match with the regular expressions. Separate regular expressions with ';'.