Created
March 28, 2014 15:08
-
-
Save iqwirty/9834983 to your computer and use it in GitHub Desktop.
Copy all files matching a pattern from one folder to another. A counter is pre-pended to ensure unique destination file names.
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
# | |
# Copy all files matching a pattern from one folder to another. A counter is pre-pended to | |
# ensure unique destination file names. | |
# | |
Clear-Host | |
$sourceFolderFullPath = "C:\SOURCE_PATH" | |
$destinationFolderFullPath = "C:\DESTINATION_PATH" | |
$filter = "FILTER*.TXT" | |
$count = 1 | |
Get-ChildItem -Path $sourceFolderFullPath -Filter $filter -Recurse | ` | |
ForEach-Object ` | |
{ | |
Write-Host "Copying $($_.FullName)..." | |
Copy-Item -Path $_.FullName ` | |
-Destination "$destinationFolderFullPath\${count} - $_" | |
$count++ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment