22

It is hard to believe but I seem to be not able to copy a folder with all its files (that begin with a certain character) and subfolders (beginning with the same character) to another folder in Windows 7. I used copy, xcopy and robocopy but all I do achieve is, that all files in the top level directory and all the subdirectories but without their content get copied. What am I doing wrong? I tried several ways, my last try was:

robocopy path\path\here x* path\path\there /E

I also tried

/COPYALL
/MIR

but with the same result.

binki
  • 7,754
  • 5
  • 64
  • 110
Largo
  • 487
  • 1
  • 5
  • 17
  • Did you look at the robocopy help for info about the syntax? (`robocopy /?` or `help robocopy` from a command prompt will get you there.) – Ken White Jun 24 '14 at 15:49
  • 1
    The issue is that the filter parameter of the copy command applies to the files, not to folders. If there is a limited depth to where these folders are, try using something like wildcards in the source/“here” parameter or the [`FOR`](https://ss64.com/nt/for.html) looping construct to loop over folders which start with a particular character and then do a full copy of those. – binki Feb 16 '21 at 18:40

2 Answers2

29

Your robocopy syntax is incorrect. Is should be:

robocopy path\path\here path\path\there x* /E
idarryl
  • 749
  • 1
  • 11
  • 21
  • Yes thank you, that is correct. But nevertheless it doesn't work. I noticed that "read only" (or "write protected, I am not sure because I use the German version) was partly marked in the properties. But changing this did not help as well. – Largo Jun 27 '14 at 12:29
  • 3
    Code: `robocopy sourcefolder\ targetfolder\ u* /E` -> This should copy all files and folders with a name starting with **u** to the target folder. _Result:_ All files are copied correctly. But instead of copying only the folders that start with a **u** it copied ALL folders AND all of the without their content. – Largo Jun 30 '14 at 08:54
  • I realise it's been a few years, but did you manage to get this working, Daniel? – Hashim Aziz Nov 19 '16 at 23:09
  • No and I neither received your comment @Hashim sorry – Largo Jul 31 '17 at 15:51
  • I know this is even older than it was the last time someone commented, but wouldn't the 'content' parameter be better suited as `\x*.*` or `x*.*` ? @Largo, did you ever get this resolved? – k1dfr0std Aug 12 '23 at 09:24
  • Thanks @k1dfr0std - unfortunately, I never solved it and even already forgot how I worked around that issue. – Largo Aug 29 '23 at 15:58
0

ROBOCOPY path\path\here path\path\there \*.* /E

binki
  • 7,754
  • 5
  • 64
  • 110
  • 6
    Please try to explain a bit more rather than giving just the answer – Chameera Dulanga Feb 25 '20 at 06:13
  • The OP wanted to copy all of the contents of any folders whose names started with a certain letter. Your command copies all contents of all folders, which is not what the OP wants. – binki Feb 16 '21 at 18:38
  • @binki Hate to say this, but, fortunately for me that is the case. I came here because of the question "How to robocopy subfolders with content" and this nails it :) – loopmode Oct 24 '22 at 20:54