The batch script, also known as batch file, actually refers to a list of several commands; whenever you double-click the file, the commands will be executed. If you want to copy files or folders from one folder to another automatically, creating a batch script is a nice choice. As for how to get the work done, please keep reading.

Windows Script/Batch File

When managing your data on PC, you may need to copy or move files and folders. The permissions set on files and folders may be changed when you move/copy them by using the Windows Explorer. Did you know this?

Windows Explorer Needs To Be Restarted: Problem Solved.

For instance, when you copy a folder/file in an NTFS partition or from one partition to another, the Windows system will regard it as the new folder/file; in this way, you will become the CREATOR OWNER since the system will take on the permissions. That’s why using script to copy files from one folder to another is necessary.

batch file

Can You Use Script to Copy Files from One Folder to Another

The Windows clipboard provides an easy way for users to copy and paste files/folder manually. The ordinary copy process seems pretty simple: select the file/folder that needs to be copied and choose copy option; open the destination; select the paste option.

Yet, do you want to automatically move files from one folder to another? The copying and pasting process can be finished quickly by using the Windows command line.

How to create batch file to copy files? How to use Windows script to copy files? Generally, it contains two stages: create batch file and create a task to run the batch file to copy files from one folder to another.

Step one: click on the Cortana icon on the taskbar (fix taskbar not working on Window 10).

Step two: type notepad into the search text box.

Step three: select Notepad app from the search result by clicking on it.

notepad

Step four: type the following script in or copy & paste it into Notepad.

@echo off

set X=<days>

set “source=C:\<Source Folder Path>”

set “destination=D:\<Destination Folder Path>”

robocopy “source” “destination” “filename with extension” /z

exit /b

  • The source folder, destination folder, and number of days can be changed due to your needs.
  • The nunber of days refers to the time interval you want to archive your folders.
  • “<>” is necessary if the source or desitination folder path includes space.

Please click here to know more about robocopy.

Step five: choose File option from the menu bar and choose Save As… from submenu.

Step six:

  • Give it a name and type in the File name text box; the file name format is <filename>.BAT.
  • Select All Files for Save as type option to change the default file type.
  • Click on the Save button at the bottom to finish this step.

Stage Two: Create Task to Run Batch File

After finish this stage, you can use the batch file to copy folder to another location.

Step one: type task scheduler into the Cortana search box.

Step two: choose Task Scheduler from the search result.

Step three: find Actions section from the right-hand panel.

Step four: select Create Task… from the list.

Create Task

Step five: give a name for the task and type it into the text box after Name.

Step six: shift to Triggers tab and click on the New… button.

Step seven: define the frequency to trigger the task, choosing from One time, Daily, Weekly, and Monthly.

Step eight: set the Start time to decide when the task will be triggered and click on the OK button to confirm.

set trigger time

Step nine: shift to Actions tab and click on the New… button.

Step ten: click on the Browse button to find & choose the .BAT file you have created in stage one.

Step eleven: click on the OK button to confirm. Then, you can close the Task Scheduler and start to move file from one folder to another by using it.

choose the .BAT file

That’s how to use Windows batch to copy file. Besides, you can also use Xcopy or Robocopy to copy files and folders on your PC.

  • linkedin
  • reddit