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?
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?
Please use azcopy in Powershell to acheive this.
azcopy login
azcopy copy 'https://<SourceStorageaccount>.blob.core.windows.net/<SourceContainer>/<SourceFile>' 'https://<DestinationStorageaccount>.blob.core.windows.net/<DestinationContainer>/<DestinationFile>'
The AzCopy command-line utility offers high-performance, scriptable data transfer for Azure Storage. You can use AzCopy to transfer data to and from Blob storage and Azure Files.
Alternatively, I think this can also be used:
Start-AzStorageBlobCopy -SrcBlob "SourceFolder/SourceFile" -SrcContainer "<SourceContainer>" -DestContainer "<DestinationContainer>" -DestBlob "DestinationFolder/DestinationFile"
At the moment, there seems to be no Powershell cmdlets in the Az.Storage module to move files. They would have to be copied to the destination and deleted from the source.
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
}
Adding more info to the above suggestion, the easiest way is to use Storage Explorer
This So thread provides some idea (PS) on your query.