Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move the files from one folder to other folder in Storage Account Container

I have Storage Account in Azure which contains files inside the folders. I want to move the .txt and .csv files from one folder to other folder in same Storage Account Container using PowerShell script.

So, can anyone suggest me how to do that?

like image 980
Pradeep Avatar asked Dec 28 '25 19:12

Pradeep


1 Answers

Add the complete steps with Swishonary's reply:

$context = New-AzureStorageContext -StorageAccountName {accountName} -StorageAccountKey {Enter your storage account key here}
$Blobs = Get-AzStorageBlob -Container "SourceContainer" -Blob SourceFolder/*.csv -Context $context
foreach ($blob in $Blobs) {
    $blob.Name

    # Copy to DestinationFolder
    Start-AzStorageBlobCopy -SrcBlob "SourceFolder/SourceFile" -SrcContainer "<SourceContainer>" -DestContainer "<DestinationContainer>" -DestBlob "DestinationFolder/DestinationFile"

    # Delete the source blob
    Remove-AzStorageBlob -Container "SourceContainer" -Blob $blob.Name
}
like image 197
unknown Avatar answered Dec 30 '25 17:12

unknown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!