Ah, finally found it. Putting an asterisk * behind the filename will do the trick. So, for any of you with the same problem:
XCOPY "abc\def\001.jpg" "D:\newphotos\abc\def\001.jpg*"
This does the trick.
Question
I am trying to get the following done.
Let's say I have a directory stucture like this
C:\photos\all\abc\def\001.jpg
C:\photos\all\abc\def\002.jpg
C:\photos\all\abc\def\003.jpg
C:\photos\all\xyz\111.jpg
C:\photos\all\xyz\222.jpg
etc.
I want to use XCOPY to copy certain files to another base directory, but I want to keep the structure of the folders. So, for example I want to copy 3 files from the example above to another disk.
D:\newphotos\abc\def\001.jpg
D:\newphotos\abc\def\002.jpg
D:\newphotos\xyz\111.jpg
How can I achieve this?
I tried the following but none seems to do what I want (i ran those from C:\photos\all)
XCOPY "abc\def\001.jpg" "D:\newphotos\abc\def\001.jpg" (keeps asking if it is a file or folder)
XCOPY "abc\def\001.jpg" "D:\newphotos\" (doesn't create the target folder structure)
XCOPY /S "abc\def\001.jpg" "D:\newphotos\" (doesn't create the target folder structure)
Solution
Ah, finally found it. Putting an asterisk * behind the filename will do the trick. So, for any of you with the same problem:
XCOPY "abc\def\001.jpg" "D:\newphotos\abc\def\001.jpg*"
This does the trick.