I have a source directory structure and a destination directory structure. The destination directory structure is a sub-set of the source directory structure. That is, in the destination directory structure certain sub-folders are not present.
I want to copy certain files, lets say *.jpg, from the source to the destination and I don't want to create the missing folders at the destination. I think, for this reason I cannot use robocopy or xcopy as they would re-create the source-structure at destination when using the /S /E switches.
So the situation looks like:
source
folder1
subfolder1
file1.jpg
folder2
file2.jpg
folder3
file3.jpg
destination (before copying)
folder1
subfolder1
folder3
destination (after copying)
folder1
subfolder1
file1.jpg
folder3
file3.jpg
I tried using something like this:
@echo off
setlocal EnableDelayedExpansion
set src_dir=l:\DP\
set dest_dir=l:\test
for /R "%src_dir%" %%x in (*.jpg) do (
copy "%%x" "%dest_dir%\%%x"
)
I am pretty sure the problem is with "%dest_dir%\%%x" but no idea how to fix it. The English translation of the error message I get is "The syntax for the file, directory or drive is wrong."
Thanks for your help in advance!