Skip to content

Instantly share code, notes, and snippets.

@timgaunt
Last active May 8, 2018 08:55
Show Gist options
  • Save timgaunt/3ca3b92745ff3f663aa7bd042f9fe7d5 to your computer and use it in GitHub Desktop.
Save timgaunt/3ca3b92745ff3f663aa7bd042f9fe7d5 to your computer and use it in GitHub Desktop.
Powershell to move from one folder to another based on file list
$file_list = Get-Content "C:\files.txt"
$search_folder = "C:\from"
$destination_folder = "C:\to"
foreach ($file in $file_list) { $file_to_move = Get-ChildItem -Path $search_folder -Filter $file -Recurse -ErrorAction SilentlyContinue -Force | % { $_.FullName};if ($file_to_move) { Move-Item $file_to_move $destination_folder; } }
$file_list = Get-Content "C:\files.txt"
$search_folder = "C:\from"
$destination_folder = "C:\to"
foreach ($file in $file_list) {
$file_to_move = Get-ChildItem -Path $search_folder -Filter $file -Recurse -ErrorAction SilentlyContinue -Force | % { $_.FullName}
if ($file_to_move) {
Move-Item $file_to_move $destination_folder
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment