Copy files modified in last X days in Windows using a PowerShell alternative replacement

Copying files modified in last X days is a common requirement for backups, file synchronization, and efficient file management. Copywhiz and PowerShell are two such tools. This blog will guide you through both methods.

What is Copywhiz?

Copywhiz enhances your file-copy experience by letting you to have more flexibility & control over the file copying and backup process.

Here is how Copywhiz makes file copying a breeze:

  • Copy only new or modified files
  • Easily pick files by name, extension, folder etc from bunch of folders
  • Automatically organize files based on file attributes and metadata
  • Copy files to multiple folders/computers
  • Copy files from multiple folders and paste them at once
  • Sync files between source and destination
  • Pick files from multiple folders and compress in single .zip file
  • Schedule file backups
  • Verify copied files for data integrity
  • Retain security attributes of files & folders (ownership/user access)
  • Several more hidden nuggets designed to make your file-copy task easier.

An image showing one of Copywhiz’s feature

Using Copywhiz:

Here is a short video that shows how to achieve the above mentioned feature:

Video Transcript:

  1. In this video, we will copy which files were created/modified/accessed in the past X days.
  2. Select the folder, right-click and add it to Copywhiz.
  3. Go to the destination folder, right-click and choose Copywhiz Paste Advanced.
  4. In the Source Tab, go to the ‘Paste by date’ section.
  5. Select the criteria and mention the number of days.
  6. As in the video shown, you can see the preview.
  7. We can mention a date range as well.

Using PowerShell

You can use PowerShell to copy files based on their modification time.

Example:

To copy files modified in the last 7 days:

$source = “C:\path\to\source”
$destination = “C:\path\to\destination”
$days = 7

Get-ChildItem -Path $source -File | Where-Object { $_.LastWriteTime -ge (Get-Date).AddDays(-$days) } | ForEach-Object {Copy-Item $_.FullName -Destination $destination}

Explanation:

Get-ChildItem: Lists all files in the source directory.

Where-Object { $_.LastWriteTime -ge (Get-Date).AddDays(-$days) }: Filters files modified in the last X days.

Copy-Item: Copies the files to the destination folder.


Conclusion

Copywhiz is an advanced, user friendly file copy and backup tool.

Learn more about Copywhiz. Download the free trial from here.

For short tutorial videos, Check out this page.

Subscribe to our YouTube channel for interesting videos.

Check out our other cool products.

Have a good day!

Thanks for reading :)

Leave a Reply

Your email address will not be published. Required fields are marked *