Search code examples
powershellscriptingmovedirectory

PowerShell Script to move folders from A to B based on names


Im looking for a PS script that will move a folder and/or folders with a specific string in the folder name (in this case S0) to another folder containing something specific (in this case (-= Shows)

Example:

ThatonefunnyshowS01E01
ThatonefunnyshowS01E02
ThatonefunnyshowS01E03
ThatonefunnyshowS01E04

I would like the PS script to "scan" the S:\ on my PC and move all folders with S0 into the directory below. If it cant scan, I can run it from the specific directory where they live and that will work too.

The paths are

Source is S:\ -= Downloads\
Destination is S:\ -= Shows\


Solution

  • Get-ChildItem S:\Downloads\*S0* | Move-Item -Destination S:\Shows