Search code examples
powershellazure-blob-storageazcopy

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


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?


Solution

  • 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