Last active
May 8, 2018 08:55
-
-
Save timgaunt/3ca3b92745ff3f663aa7bd042f9fe7d5 to your computer and use it in GitHub Desktop.
Powershell to move from one folder to another based on file list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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