What is the windows command line command to copy documents?

What is the windows regulate punctual command to copy documents?

I require to relocate a documents from area A to area B. Also if the folder for area B does not' exists I intend to have it developed.

I require this to be a command line so I can automate it.

The variation of Windows is XP.

2019-05-13 04:15:04
Source Share
Answers: 5

Use md to create the folder (it is alright if it currently exists)

Use copy or action for documents, and also xcopy for folders

2019-05-17 17:29:15

In a set documents:

if not exists locationB\nul mkdir locationB
copy locationA\file locationB

if not exists checks the parameter to see if it exists, yet it just works with documents. To look for presence of a directory site , you require to seek a 'quasi - documents' called "nul" - monitoring for presence of this documents will certainly constantly return real if the directory site exists.

The copy line duplicates the documents called file in directory site locationA to locationB and also names the documents the very same point. If you intend to relabel the documents at the very same time, you can do that also:

copy locationA\file locationB\newfilename
2019-05-17 17:06:51

xcopy will certainly create the directory site framework for you. Method is to make use of the/ I alternative and also toss an asterisk at the end of the documents name so xcopy assumes you are replicating numerous documents, or else it asks you if the target name is the documents name you desire, or the directory site name you desire. As an example.

xcopy /I c:\<SourceDir>\<SourceFile> c:\<TargetDirThatDoesNOTExist>

I would certainly additionally consider RoboCopy, yet you require to get it from the source package as it is not in Windows till Vista.

2019-05-17 17:05:52

If you desire the capacity to synchronise the copy and also various other innovative attributes (overlook particular folders, just include particular wildcards) after that consider robocopy. Consisted of in Vista and also past, optional (from source package devices) in earlier variations.

2019-05-17 16:46:08

The command xcopy is what you are seeking. Instance:

xcopy source destination /E /C /H /R /K /O /Y

The command above will certainly copy resource to location, documents and also directory sites (consisting of vacant ones), will certainly not stop on mistake, will certainly copy surprise and also system documents, will certainly overwrite read just documents, will certainly maintain features and also ownership/ACL details, and also will certainly subdue the motivating for overwrite existing location documents.

/E    Copies directories and subdirectories, including empty ones.
      Same as /S /E. May be used to modify /T.
/C    Continues copying even if errors occur.
/H    Copies hidden and system files also.
/R    Overwrites read-only files.
/K    Copies attributes. Normal Xcopy will reset read-only attributes.
/O    Copies file ownership and ACL information.
/Y    Suppresses prompting to confirm you want to overwrite an
      existing destination file.

For even more details type xcopy /? and also your command line.

2019-05-17 15:57:16