2

I have two folders src and dest:

src
  --new.txt
  --style.css

dest
  --text.txt
  --install.bat

I would like to copy all files inside src into dest. I have tried copy src dest but that destroys everything that is inside dest.

Is they a way to copy all files/folders inside src into dest ?

how the dest folder should be after the copy:

dest
  --text.txt
  --new.txt
  --style.css
  --install.bat
2

xcopy /s src\*.* dest doesn't work for you?

If you specify only the folder, it replaces the entire folder for you. When you specify the items inside the folder (with *.*), it copies the actual files instead of the folder.

Example below:

C:\Users\User>xcopy /s test\*.* test2
test\1.txt
test\2.txt
2 File(s) copied

C:\Users\User>dir test2
 Volume in drive C has no label.
 Volume Serial Number is 3018-ED8A

 Directory of C:\Users\User\test2

06/02/2014  09:38 AM    <DIR>          .
06/02/2014  09:38 AM    <DIR>          ..
06/02/2014  09:37 AM                 5 1.txt
06/02/2014  09:37 AM                 5 2.txt
06/02/2014  09:37 AM                 5 3.txt
  • Actually this doesn't work either because I would like to copy the folders that are in src too – edi9999 Feb 6 '14 at 17:14
  • @edi9999 edited – Canadian Luke Feb 6 '14 at 17:16
  • I get "The syntax of the command is incorrect. " My command : copy C:\\wamp\\www\\poker-tell\\server\\*.* C:\\wamp\\www\\poker-tell\\build\\window /s – edi9999 Feb 6 '14 at 17:26
  • Why are you using double backslashes? And the /s should go before the paths – Canadian Luke Feb 6 '14 at 17:28
  • This command : copy /s C:\wamp\www\poker-tell\server\*.* C:\wamp\www\poker-tell\build\window raises the same error – edi9999 Feb 6 '14 at 17:31
2

I finally used

robocopy src\ dest /E

which is able to copy even files with long paths.

1

I think You should use xcopy command. It copies all file structure within the directory:

xcopy src dest /s /e

This two parameters instruct it to copy all files directories within src including empty ones

  • I get "insufficient memory" (seems that the content of the paths of some of the files exceed 254) – edi9999 Feb 6 '14 at 17:24
  • Well, it's possible. Why do You need it to do in CLI anyway - maybe it's easier to do another way? Using third-party utils? – AKarpun Feb 6 '14 at 17:43
  • I needed it to be done in command line because it's a task I wanted to do often (it's part off the creation of an installer) – edi9999 Feb 6 '14 at 19:51
  • Robocopy is a replacement for xcopy and as such is probably better going forward. – dr.nixon Feb 18 '14 at 23:30
0
copy scr dest

should be enough altough it will not copy subdirectories

if you have same file in the destination folder you should have a message like this one:

C:\>copy tmp tmp2
tmp\bifish.txt
tmp\mal.log
Overwrite tmp2\mal.log? (Yes/No/All): no
tmp\png_create_201401.sql
tmp\png_data_201401.sql
        3 file(s) copied.
  • I would like to copy subdirectories too... – edi9999 Feb 6 '14 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.