Saturday 21 August 2021

Copy folders and sub folders using batch file

Batch file can be used to automate copying files from one folder to another folder. We can use xcopy command to copy files and folder. For this demo I have created two folders with names Source and Destination. In source folder we have placed two files and one folder. We want to copy files and folder from Source folder to Destination folder.

Please follow below steps:-

1)Open notepad.

2)Type following code in notepad and save file with .bat extension.

@echo off

xcopy /i/s "D:\Source" "D:\Destination"

pause

3)Run the file by clicking on it.

We have used xcopy command to copy files from source folder to destination folder.

Syntax of command is like this:-

   xcopy /i/s "Source Folder Path" "Destination Folder Path"

          where /i - Displays a list of files that are to be copied.

                   /s  -Copies directories and subdirectories, unless they are empty. 


Copy folders and sub folders using batch file




No comments:

Post a Comment