AzCopy list - How to show name list file without another info

2.7k views Asked by At

I want to create variable from azcopy list output. but the output will show like this :

INFO: KeyPointTips.pdf; Content Length: 98.29 KiB

Is there a way to make the output from the azcopy list only showing the file name and format, without any other information?

1

There are 1 answers

1
Shayki Abramczyk On BEST ANSWER

If it's always with the same convention you can retrieve the file name with regex or with simple splits:

$azOutput = "INFO: KeyPointTips.pdf; Content Length: 98.29 KiB"

$fileName = $azOutput.Split(':')[1].Split(';')[0].Trim()

Write-Host $fileName 
# KeyPointTips.pdf