How to Automatically Copy Files From One Folder to Another on Windows 11

You can automate this process using the Task Scheduler

Reading time icon 3 min. read


Readers help support Windows Report. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help Windows Report sustain the editorial team Read more

Key notes

  • To copy files from one folder to another automatically on Windows 11, you need to use batch files.
  • If this is too complicated for you, there are many third-party solutions that can help.
automatically copy files from one folder to another

It’s important to keep a backup of important files and you can easily automatically copy files from one folder to another on your PC with built-in tools.

Windows already has commands that allow you to copy files, and in this guide, we’ll show you how to utilize them to automate the copying process.

How to automatically copy files from one folder to another in Windows 11?

1. Create a batch file

  1. Open Notepad.
  2. Paste the following code, but be sure to adjust the source folder and destination folder values so that they match the paths on your PC:
    @echo off set "source=C:\Users\WindowsReport\Downloads" set "destination=D:\Backup" robocopy "%source%" "%destination%" exit /b
  3. Click on File and choose Save as.
  4. Set the save directory, set the file type to All files, and set the name to copyfiles.bat.
  5. Save changes.

2. Create a scheduled task to run the script

  1. In the search box type task. Select Task Scheduler from the list.
     
  2. Click on Create Basic Task.
  3. Next, set the name and description for your task and click on Next.
  4. Set how the task will trigger. We used When the computer starts, but you can set the task to run every few days or every week.
  5. Select Start a program.
  6. Next, click the Browse button.
  7. Select the batch file copyfiles.bat that you created.
  8. Lastly, click on Finish to add a new task.

3. Use third-party software

  1. Download FreeFileSync and install it.
  2. Start the application.
  3. Click Browse and choose the file path for both the source and target directory.
     
  4. Next, select the desired sync method.
  5. Lastly, click on Synchronize.

In case you’re having issues with this tool, you can use any other file sync software.

Batch script to move files from one folder to another based on date/name

To move files based on their name, use the following script, just manually set the file pattern as well as the source and destination directory:

@echo off
set "sourceFolder=C:\SourceFolder"
set "destinationFolder=C:\DestinationFolder"
set "filePattern=*2010*"

for %%F in ("%sourceFolder%\%filePattern%") do (
    move "%%F" "%destinationFolder%"
)

echo Files moved based on file name pattern.
pause

To move files based on their modified date, use the following script:

@echo off
set "sourceFolder=C:\SourceFolder"
set "destinationFolder=C:\DestinationFolder"
set "cutoffDate=2023-01-01"

for /f %%F in ('dir /b /a-d /o-d %sourceFolder%') do (
    set "fileDate="
    for /f %%D in ('wmic datafile where name^="%sourceFolder%\%%F" get LastModified ^| findstr /r "^[0-9]"') do (
        set "fileDate=%%D"
    )
    
    if defined fileDate (
        if "%fileDate%" LSS "%cutoffDate%" (
            robocopy "%sourceFolder%" "%destinationFolder%" "%%F"
        )
    )
)

echo Files moved based on date cutoff.
pause

As you can see, it’s relatively simple to use a script to copy files from one folder to another automatically on Windows 11. To better understand how these commands work, we suggest learning how to copy files using Command Prompt.

To ensure that everything is working as it should, it’s a good idea to compare folders and copy missing files accordingly. For more information on file management, visit our guide on how to extract files from multiple folders.

What method do you use to copy files automatically on your PC? Share it with us in the comments section below!

More about the topics: command prompt, Windows 11 guides