How to Copy file with Batch Script

MD Aminul Islam Feb 02, 2024
  1. Using the XCOPY to copy the file into a new direction
  2. Using the COPY to copy the file into a new direction
  3. Using the ROBOCOPY to copy the file into a new direction
How to Copy file with Batch Script

Batch Script is a script specially built for windows command lines to perform various tasks and execute the sequence of commands instructed by the user. The batch script makes it easy to use Windows PowerShell.
This tutorial will introduce how to copy a file from one directory to another using the Batch script. We will discuss three methods here.

Using the XCOPY to copy the file into a new direction

Using the xcopy we can easily copy a file from one directory to another directory. The general format for this command is xcopy G:\source G:\destination

xcopy G:\Capture.jpg G:\Cases\

Using the COPY to copy the file into a new direction

We can use the command copy to copy the file. The general format for this command is copy G:\source G:\destination

copy G:\Capture.jpg G:\Cases\

Using the ROBOCOPY to copy the file into a new direction

The fastest and easiest way to copy all files in a directory into another directory is using the command robocopy. The basic syntax for this command is robocopy G:\sourceFolder\data G:\destinationFolder\data

robocopy  D:\source\data E:\destination\data

All of the methods discussed above are only for Windows environments.

MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn

Related Article - Batch Script