How to Move Files from One Folder to Another Using PowerShell (With Date Filtering)

Managing files on Windows systems often involves organizing, archiving, or cleaning up folders based on file dates. For example, you might want to move files older than 30 days to an archive folder, separate last month’s reports, or relocate recently created files to another directory for processing.

This is where PowerShell becomes extremely helpful. PowerShell provides powerful file management capabilities that allow you to filter files based on properties like creation date, last modified date, or last accessed date, and then perform actions such as moving them to another folder.

In this tutorial, you will learn how to move files from one folder to another using PowerShell with date filtering. We will go through practical examples showing how to move files older than a certain number of days, move files created after a specific date, etc.

Why Use PowerShell Instead of Doing It Manually?

Before we jump in, you might be thinking: “Can’t I just drag and drop files?”

Sure, if you’ve got 10 files. But what if you need to:

  • Move all files older than 30 days
  • Move files created in January 2026
  • Move only PDF files modified last week
  • Do this same task every month

That’s where PowerShell becomes your best friend. You write the command once, and you can run it whenever you need it.

Move Files from One Folder to Another Using Move-Item

The core command you’ll use is Move-Item. It’s that simple.

Here’s the most basic version:

Move-Item -Path "C:\Source\file.txt" -Destination "C:\Destination\"

This moves file.txt from the Source folder to the Destination folder. In the example below, I used two temp folders on the C and D drives to move files.

move files using powershell

After running the PowerShell script, the file is moved from the source folder to the destination folder, as shown in the image below.

move files from one folder to another using powershell script

But we’re not here for basic stuff. Let’s get into the date-based moving.

Check out How to Find a Folder by Name in PowerShell?

Move Files Based on Creation Date

Let’s say you want to move all files created in the last 7 days.

Here’s how you do it using PowerShell:

$source = "C:\Source"
$destination = "C:\Destination"
$days = 7

Get-ChildItem -Path $source | Where-Object { $_.CreationTime -gt (Get-Date).AddDays(-$days) } | Move-Item -Destination $destination

You can see the exact output in the screenshot below:

powershell move files to folder based on date created

Let me break this down:

  • $source and $destination are variables. Think of them as nicknames for your folder paths. Makes things easier to read.
  • Get-ChildItem lists all files in the source folder
  • Where-Object filters the files based on conditions
  • $_.CreationTime refers to when each file was created
  • -gt means “greater than” (so newer than)
  • (Get-Date).AddDays(-7) gives you the date from 7 days ago
  • Move-Item actually moves the files

Below you can see the results file was created 7 days ago, now it has been moved into the destination folder I mentioned.

powershell move files based on date

Read Check if a File’s LastWriteTime is Greater Than a Specific Date in PowerShell

Move Files Based on Modified Date

Sometimes you don’t care when a file was created. You care when it was last modified.

$source = "C:\Source"
$destination = "C:\Destination"
$days = 30

Get-ChildItem -Path $source | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | Move-Item -Destination $destination

Notice I changed CreationTime to LastWriteTime and -gt to -lt (less than). This moves files that haven’t been modified in the last 30 days. Perfect for archiving old stuff.

Moving Files from a Specific Date Range

What if you want files from January 2026 only?

$source = "C:\Source"
$destination = "C:\Destination"
$startDate = Get-Date "2026-01-01"
$endDate = Get-Date "2026-01-31"

Get-ChildItem -Path $source | Where-Object { $_.CreationTime -ge $startDate -and $_.CreationTime -le $endDate } | Move-Item -Destination $destination

Update the $source and $destination variables with your folder location.

move files from a specific date range powershell

Here’s what changed:

  • We defined $startDate and $endDate
  • Used -ge (greater than or equal to) and -le (less than or equal to)
  • Added -and to combine both conditions

You can see the exact output in the screenshot below:

powershell move files based on a specific date range

Check out Convert Excel Files to CSV Using PowerShell

Include Subfolders

By default, Get-ChildItem only looks at files in the main folder. If you want to include subfolders:

$source = "C:\Source"
$destination = "C:\Destination"
$days = 30

Get-ChildItem -Path $source -Recurse | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | Move-Item -Destination $destination

Just add -Recurse after the path. That’s it.

Warning: This will move files from subfolders but won’t preserve the folder structure. All files end up directly in the destination folder. We’ll fix this in a bit.

Filter by File Type

Maybe you only want to move PDF files or Excel files.

$source = "C:\Source"
$destination = "C:\Destination"
$days = 7

Get-ChildItem -Path $source -Filter "*.pdf" | Where-Object { $_.CreationTime -gt (Get-Date).AddDays(-$days) } | Move-Item -Destination $destination

Here is the cmd I executed using PowerShell ISE.

powershell move files based on filetype

The -Filter "*.pdf" part does the magic. Replace “pdf” with whatever extension you need:

  • *.xlsx for Excel files
  • *.docx for Word documents
  • *.jpg for images

You can see the exact output in the screenshot below:

powershell move files based on filetype pdf

Check out PowerShell Find File by Name Wildcard Examples

Preserve Folder Structure

Remember that problem with subfolders? Here’s how you keep the folder structure intact:

$source = "C:\Source"
$destination = "C:\Destination"
$days = 30

Get-ChildItem -Path $source -Recurse | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | ForEach-Object {
    $destPath = Join-Path $destination $_.FullName.Substring($source.Length)
    $destDir = Split-Path $destPath
    if (!(Test-Path $destDir)) {
        New-Item -ItemType Directory -Path $destDir -Force
    }
    Move-Item $_.FullName -Destination $destPath
}

This is more complex, but here’s what it does:

  • Calculates where each file should go in the destination
  • Creates the necessary folders if they don’t exist
  • Moves the file to the correct location

Testing Before You Move (Important!)

Here’s a pro tip: always test your command before actually moving files.

Replace Move-Item with Select-Object Name, CreationTime to just list the files that would be moved:

$source = "C:\Source"
$days = 30

Get-ChildItem -Path $source | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | Select-Object Name, CreationTime

This shows you exactly which files match your criteria without moving anything. Once you’re happy with the results, swap back to Move-Item.

Read Find the Most Recent File in a Directory with PowerShell

Copy Instead of Move Files

Maybe you don’t want to move files. Maybe you want to copy them and keep the originals.

Just replace Move-Item with Copy-Item:

$source = "C:\Source"
$destination = "C:\Destination"
$days = 7

Get-ChildItem -Path $source | Where-Object { $_.CreationTime -gt (Get-Date).AddDays(-$days) } | Copy-Item -Destination $destination
powershell copy file from one folder to another

Same logic, different action.

You can see the exact output in the screenshot below:

powershell copy folder and subfolders

Handling Errors

Sometimes files are in use, or you don’t have permission. Add error handling:

$source = "C:\Source"
$destination = "C:\Destination"
$days = 30

Get-ChildItem -Path $source | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | ForEach-Object {
    try {
        Move-Item $_.FullName -Destination $destination -ErrorAction Stop
        Write-Host "Moved: $($_.Name)" -ForegroundColor Green
    }
    catch {
        Write-Host "Failed to move: $($_.Name) - $($_.Exception.Message)" -ForegroundColor Red
    }
}

This tries to move each file. If it works, you see a green message. If it fails, you see a red error message, but the script keeps going.

Check out Find Passwords in Files with PowerShell

Creating a Log File

For keeping track of what happened:

$source = "C:\Source"
$destination = "C:\Destination"
$days = 30
$logFile = "C:\Logs\MoveLog.txt"

Get-ChildItem -Path $source | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | ForEach-Object {
    try {
        Move-Item $_.FullName -Destination $destination -ErrorAction Stop
        Add-Content -Path $logFile -Value "$(Get-Date) - Moved: $($_.Name)"
    }
    catch {
        Add-Content -Path $logFile -Value "$(Get-Date) - Failed: $($_.Name) - $($_.Exception.Message)"
    }
}

Now you have a permanent record in a text file.

Automating with Task Scheduler

Once you’ve got your script working, save it as a .ps1 file. Let’s call it MoveOldFiles.ps1.

To run it automatically:

  1. Open Task Scheduler
  2. Click “Create Basic Task”
  3. Give it a name like “Archive Old Files”
  4. Set your trigger (daily, weekly, etc.)
  5. Choose “Start a program”
  6. In “Program/script” type: powershell.exe
  7. In “Add arguments” type: -ExecutionPolicy Bypass -File "C:\Scripts\MoveOldFiles.ps1"

Now it runs automatically without you lifting a finger.

Common Mistakes to Avoid

Here are some common mistakes you should avoid while moving files from one folder to another folder.

  • Forgetting to create the destination folder: PowerShell won’t create it for you. Make sure it exists first.
  • Using the wrong date property: CreationTime, LastWriteTime, and LastAccessTime are all different. Pick the right one for your needs.
  • Not testing first: I can’t stress this enough. Always do a test run with Select-Object before using Move-Item.
  • Running as a regular user when you need admin rights: Some folders need administrator privileges. Right-click PowerShell and choose “Run as Administrator” if needed.

Real-World Example: Cleaning Up Downloads

Here’s a practical script I use myself:

$downloads = "$env:USERPROFILE\Downloads"
$archive = "$env:USERPROFILE\Documents\OldDownloads"
$days = 90

# Create archive folder if it doesn't exist
if (!(Test-Path $archive)) {
    New-Item -ItemType Directory -Path $archive
}

# Move files older than 90 days
Get-ChildItem -Path $downloads -File | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-$days) } | Move-Item -Destination $archive

Write-Host "Cleanup complete. Moved files older than $days days to $archive"

This keeps my Downloads folder clean by archiving anything older than 90 days.

Wrapping Up

Moving files based on dates in PowerShell isn’t rocket science. You just need:

  • Get-ChildItem to list files
  • Where-Object to filter by date
  • Move-Item to actually move them

Start simple. Test your commands. Build up to more complex scenarios as you get comfortable.

The beauty of PowerShell is that you can save these commands and reuse them. Write it once, run it forever.

And if you mess up? Well, that’s what backups are for. Always have a backup before running scripts on important files.

You may also like the following tutorials:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.