Copying all files from one folder to an other with command line in windows
2014-04
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
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
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 finally used
robocopy src\ dest /E
which is able to copy even files with long paths.
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 need to track changes to folders with files like jpg or docx, and make a copy to another folder.
I need to make a copy of the file when it changes, keeping the filename and adding the current datetime.
SOURCE: mydoc.docx
TARGET:
mydoc.20111224080000.docx //Changed at 08:00:00
And if I change mydoc.docx a little later target would look like this:
TARGET:
mydoc.20111224080000.docx //Changed at 08:00:00
mydoc.20111224080200.docx //Changed at 08:02:00
The comparison should allways be against the newest file in the TARGET folder.
I need to run in the background, monitoring the folder og in time intervals.
Is there a program that I can use?
One type of program you could use is a version control program. They were originally designed for keeping track of changes to source code, but you can use them with virtually any type of file.
You put all the files you want to have version of into it and then when you edit the file it basically takes a copy. You need to remember to check the file back into the repository for each version you want to keep.
You can get any version back out of the system and anyone you give access to can edit the files as well.