From a source directory structure (multiple folders), I need to copy all csv files to a single target directory. I found a command to do this, though files of the same name exist within different folders of the source structure, causing obvious issues when copied to one folder.

How can the files with duplicate names be renamed during the copy please (ideally: report.csv, reportcopy2.csv etc)? The job currently only copies a single instance of each file. Thanks for help.

As it is now it will just echo copy command instead of executing it, so you can safely run it and check it's output. When you're ready, just remove echo fromecho copy "%~2" "%targetPath%\%~n1%sufix%%~x1%"