Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Source = '' #provide the absolute path of the source directory
- $Files = '*txt'
- $Dest = 'C:\Temp'
- Get-ChildItem $Source -Filter $Files -Recurse | ForEach {
- $Path = ($_.DirectoryName + "\") -Replace [Regex]::Escape($Source), $Dest
- If(!(Test-Path $Path)){
- New-Item -ItemType Directory -Path $Path -Force | Out-Null
- Copy-Item $_.FullName -Destination $Path -Force
- }
- }
- $ZIP = "C:\Program Files\7-Zip\7z.exe"
- $allCompressedFiles_gz = Get-ChildItem -Path C:\Temp\MS -Recurse -File
- foreach ($gzFile in $allCompressedFiles_gz) {
- $filePath = Split-Path -Path $gzFile.FullName -Parent -Resolve
- $fileName = Split-Path -Path $gzFile.FullName -Leaf -Resolve
- Write-Host $fileName
- #$filePath = (get-item ($gzFile.FullName) ).parent.Parent
- #write-host $filePath
- set-location -Path $filePath
- if ( $fileName -like "*gz" ) {
- & $ZIP e $fileName
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement