Often there will be times when you will not really want to just copy one file or files but the whole folder! No matter what is inside, be it files or more folders meaning sub-folders, you just want to copy of move the whole folder.
This is process in computer science called ‘pruning and grafting’. This is a process of cutting parts of decision trees to add clarity and grafting is the process of adding nodes to the decision trees in order to predict its accuracy. This may sound all too technical and jumbled, but know that this is one of the places where the command line will help you hundred times better than a regular GUI.
The xcopy command on Windows
Generally in Windows, the standard command like copy and move works only in one directory at a time. This is inefficient if we have to copy or move files to or from multiple directories. To help you with such task, Microsoft did take care of it for you.
Xcopy is the command you want to use in such scenario. This is similar to the copy command but has insane power and switches to boost your workflow. This all may sound too abstract, so let’s jump right in and see an example of this.
The xcopy command in action – an example
Let’s say we have a folder or directory called ‘KingDiamond’ inside our root C: drive. Under this ‘KingDiamond’ folder we have sub-directories called , studio albums, live, bootleg and each of these sub-directories has something around 100 files. Now, I want to copy all of this King diamond folder to the drive D: including all of its files and folders. So, we would accomplish this task with the syntax like this – xcopy c:\KingDiamon d:\KingDiamond /s.
Use a wildcard
This incredibly more powerful than standard copying because if you have noticed we did not have to specify file names like we do with the copy command. Yet, if in any case you needed to use the filename and wildcards you can always go and do that. With this mighty /s switch that comes with xcopy, it enables xcopy to copy all of the files and folders inside the KingDiamond folder except for the empty ones. With the /e switch you are able to copy the empty sub-directories.
Xcopy is your go to command when you have to copy in bulk to multi directories.