Skip to main content
TopMiniSite

Back to all posts

How to Move Files From Specific Folders Only Using Powershell?

Published on
4 min read
How to Move Files From Specific Folders Only Using Powershell? image

Best PowerShell Scripts to Buy in October 2025

1 Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS

Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS

BUY & SAVE
$39.99
Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS
2 Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools

BUY & SAVE
$47.34 $59.99
Save 21%
Learn PowerShell Scripting in a Month of Lunches, Second Edition: Write and organize scripts and tools
3 PowerShell for Sysadmins: Workflow Automation Made Easy

PowerShell for Sysadmins: Workflow Automation Made Easy

  • MASTER POWERSHELL FOR SEAMLESS WORKFLOW AUTOMATION TODAY!
  • ENHANCE YOUR SYSADMIN SKILLS WITH OUR EASY-TO-FOLLOW GUIDE.
  • CONVENIENT PAPERBACK FORMAT FOR ON-THE-GO LEARNING AND REFERENCE.
BUY & SAVE
$23.99 $39.99
Save 40%
PowerShell for Sysadmins: Workflow Automation Made Easy
4 Learn PowerShell Scripting in a Month of Lunches

Learn PowerShell Scripting in a Month of Lunches

BUY & SAVE
$50.21
Learn PowerShell Scripting in a Month of Lunches
5 Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects

BUY & SAVE
$0.99
Beginner’s Guide to PowerShell Scripting: Automate Windows Administration, Master Active Directory, and Unlock Cloud DevOps with Real-World Scripts and Projects
6 Windows PowerShell in Action

Windows PowerShell in Action

  • BRAND NEW AND SEALED FOR ULTIMATE CUSTOMER CONFIDENCE!
  • COMPLETE PACKAGE: INCLUDES ALL ESSENTIAL ACCESSORIES.
  • READY TO USE: HASSLE-FREE SETUP STRAIGHT OUT OF THE BOX!
BUY & SAVE
$59.99
Windows PowerShell in Action
7 Windows PowerShell 2 For Dummies

Windows PowerShell 2 For Dummies

BUY & SAVE
$21.00 $33.99
Save 38%
Windows PowerShell 2 For Dummies
+
ONE MORE?

To move files from specific folders using PowerShell, you can use the Move-Item cmdlet along with the -Path parameter to specify the source folder and the -Destination parameter to specify the destination folder. You can also use the -Recurse parameter to include subdirectories.

For example, to move all files from a specific folder named "Source" to another folder named "Destination", you can use the following command:

Move-Item -Path "C:\Path\To\Source\*" -Destination "C:\Path\To\Destination" -Force

This command will move all files (denoted by *) from the "Source" folder to the "Destination" folder. The -Force parameter is used to overwrite any existing files with the same name in the destination folder.

You can modify the command to suit your specific requirements, such as moving files based on their extension, file name, or any other criteria. Just replace the paths and parameters as needed.

How to move files from a single folder using PowerShell?

To move files from a single folder using PowerShell, you can use the Move-Item cmdlet.

Here's an example command that moves all files from one folder to another:

Move-Item -Path "C:\sourcefolder\*" -Destination "C:\destinationfolder\"

In this command:

  • -Path "C:\sourcefolder\*" specifies the path to the source folder with a wildcard character (*) to include all files in the folder.
  • -Destination "C:\destinationfolder\" specifies the destination folder where the files will be moved.

You can also filter which files to move based on their extension or other criteria by modifying the -Path parameter accordingly.

How to move files based on their file name using PowerShell?

To move files based on their file name using PowerShell, you can use the Get-ChildItem cmdlet to get a list of files and then use a Where-Object cmdlet to filter the files based on their file name. You can then use the Move-Item cmdlet to move the files to a new location.

Here's an example of how you can move files based on their file name using PowerShell:

# Set the source and destination directories $sourceDir = "C:\Source" $destinationDir = "C:\Destination"

Get a list of files in the source directory

$files = Get-ChildItem $sourceDir

Filter the files based on their file name

$filesToMove = $files | Where-Object { $_.Name -like "*pattern*" }

Move the files to the destination directory

$filesToMove | ForEach-Object { Move-Item $_.FullName -Destination $destinationDir }

In this example, replace C:\Source with the path of the source directory where the files are located and C:\Destination with the path of the destination directory where you want to move the files. Replace *pattern* with the file name pattern you want to search for.

This script will move all files with the specified file name pattern from the source directory to the destination directory.

How to move files based on their last access date using PowerShell?

You can use the following PowerShell script to move files based on their last access date:

$sourceDirectory = "C:\Source" $destinationDirectory = "C:\Destination" $daysThreshold = 30

Get-ChildItem $sourceDirectory | Where-Object {($_.LastAccessTime -lt (Get-Date).AddDays(-$daysThreshold))} | ForEach-Object { Move-Item $_.FullName -Destination $destinationDirectory }

In this script:

  1. Set the $sourceDirectory variable to the directory containing the files you want to move.
  2. Set the $destinationDirectory variable to the directory where you want to move the files.
  3. Set the $daysThreshold variable to the number of days since the last access date that you want to use as a threshold for moving the files.
  4. The script uses the Get-ChildItem cmdlet to retrieve a list of files in the source directory.
  5. The Where-Object cmdlet filters the files based on their last access time using the $daysThreshold variable.
  6. The ForEach-Object cmdlet iterates over the filtered files and uses the Move-Item cmdlet to move each file to the destination directory.

Run the script in PowerShell to move the files based on their last access date. Adjust the source directory, destination directory, and days threshold as needed for your specific requirements.