Skip to content

Instantly share code, notes, and snippets.

@jcefoli
Last active April 24, 2024 04:23
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcefoli/b77e7f2e8d5bfd005c55 to your computer and use it in GitHub Desktop.
Save jcefoli/b77e7f2e8d5bfd005c55 to your computer and use it in GitHub Desktop.
Powershell: Move Files & Folders In Directory Recursively to Another Directory
<#
Recursively move all files in C:\SourceDir into C:\Destination
Assumes C:\Destination exists already, or there could be problems
#>
Move-Item -Path "C:\SourceDir\*" -Destination "C:\Destination"
@jcefoli
Copy link
Author

jcefoli commented Oct 15, 2021

@ChangBroot Yeah, there was some niche reason why I needed this a long time ago, but I cannot remember. It's not very practical for most use cases, but I think I needed to move files out of a directory quickly without needing to preserve paths or directories.

Most of my gists are a place I dump scripts to remember/reuse/modify them later, so any comments/feedback are welcome, but it doesn't mean that they're a copy/paste solution for everyone. Glad this helped you.

@fourthborngoose
Copy link

fourthborngoose commented Apr 6, 2022

This was an awesome find! Simplicity at it's finest.
Get-ChildItem 'dot-slash *.(file extension)' -Recurse | Move-Item -Destination 'dot-slash'
I just... I mean I... Thanks you. It was so simple I completely missed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment