Wednesday, January 30, 2019

How to Create Batch File Simple and Easy Step by Step Guide




Benefit: Batch file runs pre-defined DOS commands when it executes. We don't need to write DOS commands every time. We just write all commands in notepad and save as batch file. When batch file executes, it runs all DOS commands one by one.


So we will create a batch file to copy a file from one location to another location.


Step 1: Create two folders in 
C: drive as "Source Folder" & "Destination Folder"


Step 2: Create an excel file in this folder and rename it to "testcopy". You can create any other type file and can give any other name you like. It is just for example. 


Step 3: Open Notepad in your system.


Step 4: Write below code in Notepad:


'This command will copy testcopy excel files from source to destination folder.

Copy "C:\Source Folder\testcopy.xlsb" "C:\Destination Folder\"



Step 5: Go to 
File menu and click on Save or press Ctrl+S.


Step 6: Give any name to file and write .bat in last then Save.

    For example: Copy.bat


Step 7: Now double click on batch file and it will copy "testcopy.xlsb" file. 



Note:- If you want to edit batch file, then right click on it and then click on “Edit” or you can open batch file in Notepad and after editing you can save.




*** Copy all Excel files using batch command ***


It is very easy to copy all excel files from Source Folder to Destination Folder.


Just write the below code or change testcopy to * :


Copy "C:\Source Folder\*.xlsb" "C:\Destination Folder\"





*** Copy all files using batch command ***


It is very easy to copy all files from Source Folder to Destination Folder.


Just write the below code or change xlsb to * :


Copy "C:\Source Folder\*.*" "C:\Destination Folder\"






***** End *****


No comments:

Post a Comment