I have several files located across several directories/subfolders that I need to copy to several destinations. I currently do this using xcopy but I do it line by line, so there are several lines of code. A friend suggested that I use an array instead which is what I'm trying to do now.
I've tried several variations of getting this to work. My last variation looks like this:
@echo off
set "mansource=somelocation\location1\sourcefolder"
set "mandest=someloacation\location2\destfolder
set src[0]="%MANSOURCE%\folderA\number1.pdf"
set dest[0]="%MANDEST%\folderB\number\1"
set src[1]="%MANSOURCE%\folderC\number2.pdf"
set dest[1]="%MANDEST%\folderD\number\2"
set /a "x=0"
for /r "%mansource%" %%f in (!src!) do xcopy "%%f" "!dest!" /v/y
pause
So I know this is wrong since it doesn't work, but nothing else I've tried has worked either. Every example I've found online so far about using arrays in a batch only has a "do ( echo" command to either list what is being indexed or print a statement to the cmd prompt. I haven't been able to find any examples concerning an actual function like copying. I did have a variation of the above code but it just resulted an infinite loop with "0 files copied" repeating forever.
The idea is to have the file in src[0] copied to the locations in dest[0], then the file in src[1] and so on.
Any advice would be appreciated.
Note: Using a *.pdf wildcard will not work as there are other pdf's in these locations and I only need specific ones to be copied. Also, each file is in a different location from the next and each copy destination for that file is also different.