The above approach will work for you when debug the pipeline even through it is giving warning in the dataset.
The dataset dynamic content doesn't know about ForEach @item() at first because it belongs to pipeline dynamic content. Thats why it is giving warning in the dataset.
But at debug time, it identifies the @item() value.
Please go through the below 2 scenarios to understand it better.
Here I am using ADLS as source and target with array of files for sample and passing to the ForEach.
These are my source files.

I have Created an array variable with above names like ["sample1.csv","sample2.csv"] and passed to ForEach,
Using @item() in dataset:
Source dataset and target dataset.


You can see it is giving the same warning, but it will give the correct result when you debug. But in dataset preview, it will give the error.

Copied files to target successfully.

Using @item() inside ForEach using dataset parameters:
I have created the parameters and used in datasets.
Source:

Target:

Copy activity inside ForEach:
Source parameter @item():

sink parameter @item():

Files copied to target successfully.
