Reputation: 444
My folder C:\Downloads\Files\ has 3 .zip files.
I need to copy these files into same location and append another extension .dat
to the file.
The total files in my folder C:\Downloads\Files\
should have 6 files now (3 .zip and 3.dat)
Can anyone help me get this done?
Upvotes: 2
Views: 4244
Reputation: 58931
Use the Get-ChildItem
cmdlet to retrieve all zip files and copy them using the Copy-Item
cmdlet:
Get-ChildItem -Path 'C:\Downloads\Files\' -Filter '*.zip' |
Copy-Item -Destination { "$($_.Name).dat" }
Upvotes: 5
Reputation: 674
The following copies only files from within the $path
directory with extension .dat
.
Get-ChildItem -Path $path -File | ForEach-Object {Copy-Item -Path $_.FullName -Destination "$($_.FullName).dat"}
Upvotes: 1