How to run more than one command in powershell?

2

I have the following AWS Cli command that runs on Windows PowerShell and downloads a specific folder inside an S3 bucket:

 aws s3 cp s3://rfcarga/RF73 . --recursive

However, I have other collections of images to download as well, for example:

aws s3 cp s3://rfcarga/RF73 . --recursive
aws s3 cp s3://rfcarga/RF73A . --recursive
aws s3 cp s3://rfcarga/RF73Ba . --recursive
aws s3 cp s3://rfcarga/RF73Bb . --recursive
aws s3 cp s3://rfcarga/RF73Ca . --recursive
aws s3 cp s3://rfcarga/RF73Cb . --recursive
aws s3 cp s3://rfcarga/RF73D . --recursive

I would not like to run one by one but all in one ENTER only, how do I run multiple commands one after another at PowerShell?

    
asked by anonymous 05.11.2018 / 17:19

1 answer

2

You can use an array and pass it to the command to execute:

@("RF73", "RF73A", ...) | % { aws s3 cp s3://rfcarga/$_ . --recursive }

In this example, we create an array with the name of the images to download and pass each array element through | , at Loop Operator % .

This operator will execute the code between {} for each element present in the array and refers to the value used in this iteration through $_ .

Note:

If you just want to have multiple expressions on the same line, you can separate each expression with a ; :

aws s3 cp s3://rfcarga/RF73 . --recursive; aws s3 cp s3://rfcarga/RF73A . --recursive
    
08.11.2018 / 10:06