1. Home
  2. Windows Tips
  3. Move files from one folder to another after x days windows 10

Move Files From One Folder to Another After X Days on Windows 10

Automation is the best tool you can use if you have to perform a repetitive task. It’s not always easy to automate a task but scripting and the Task Scheduler are two great ways to get most jobs done. In very rare cases, Windows might have an automation feature or two built into it. If you need to move files from one folder to another after a certain number of days, your best option is to use a batch script.

Script to move files

Open a new Notepad file and paste the following in it. Save it with the .BAT extension. You will need to edit the file to suit your own needs and we’ll explain what edits you have to make.

@echo off

set X=30
set "source=C:\Source Folder"
set "destination=D:\Destination Folder"

robocopy "%source%" "%destination%" /mov /minage:%X%

exit /b

The first thing you need to change is the value for X in the second line. X represents the age of a file. It’s set to 30 by default but you can change it to whatever you want. If you want files that are more than 15 days old to be moved to the destination folder, change the 30 to 15.

Next, you need to change the path given in the third line. Replace it with the path to the folder you want to move files from. Make sure the path, and the “source=” are all included and closed within quotes.

Last, replace the path in the fourth line with the complete path to the folder that you want to move the files to. Again, make sure everything is closed within quotes.

That’s all it takes. Run the script and it will move files.

Scheduling the script

You can manually run the script whenever you need to move files but if you need to it to run on its own, Task Scheduler is the app for the job.

Open Task Scheduler and click Create Task. Give the task a name and go to the Triggers tab. Click the New button at the bottom and select when you need to run the script.

Next go to the Action tab and click New. Click the browse button and select the script you just created. Click Ok, and the task is complete. Enable it and it will automatically move files per the schedule you’ve given it.

Robocopy

This script uses Robocopy to move files. Robocopy is a command line utility that is included by default on Windows 10’s more recent versions. This script will work on any Windows system that has Robocopy on it but in some cases, you might have to install it yourself.