Windows - Copy all zip files from sub directories to separate folder.
Windows - Copy all zip files from sub directories to separate folder.
Please copy below script and run it in PowerShell in windows
-------------------------------------------------------------------------------------------------------
# Replace these paths with your actual source and destination directories
$sourceDirectory = "C:\path\to\source"
$destinationDirectory = "C:\path\to\destination"
# Check if the destination directory exists, and create it if not
if (-not (Test-Path -Path $destinationDirectory -PathType Container)) {
New-Item -ItemType Directory -Force -Path $destinationDirectory
Write-Host "Created destination directory: $($destinationDirectory)"
}
# Get all zip files in subdirectories containing "extract" in the path
$zipFiles = Get-ChildItem -Path $sourceDirectory -Recurse -Filter *.zip | Where-Object { $_.FullName -like "*extract*" }
# Copy each zip file to the destination directory
foreach ($zipFile in $zipFiles) {
$destinationPath = Join-Path -Path $destinationDirectory -ChildPath $zipFile.Name
Copy-Item -Path $zipFile.FullName -Destination $destinationPath -Force
Write-Host "Copied $($zipFile.Name) to $($destinationPath)"
}
Get Updates
Subscribe to our e-mail to receive updates.
0 Responses to “Windows - Copy all zip files from sub directories to separate folder.”
Post a Comment
Thanks for your comments