Untitled
unknown
plain_text
2 years ago
807 B
8
Indexable
# Set the source folder where you want to start searching for .txt files
$sourceFolder = "C:\your\source\folder"
# Set the destination folder where you want to copy the .txt files
$destinationFolder = "C:\txtfiles"
# Create the destination folder if it doesn't exist
if (-not (Test-Path $destinationFolder)) {
New-Item -ItemType Directory -Path $destinationFolder | Out-Null
}
# Get all .txt files recursively from the source folder and its subfolders
$txtFiles = Get-ChildItem $sourceFolder -Filter "*.txt" -Recurse
# Copy each .txt file to the destination folder
foreach ($txtFile in $txtFiles) {
$destinationPath = Join-Path $destinationFolder $txtFile.Name
Copy-Item $txtFile.FullName -Destination $destinationPath
}
Write-Host "All .txt files have been copied to $destinationFolder."Editor is loading...