Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. $Source = '' #provide the absolute path of the source directory
  2. $Files = '*txt'
  3. $Dest = 'C:\Temp'
  4. Get-ChildItem $Source -Filter $Files -Recurse | ForEach {
  5. $Path = ($_.DirectoryName + "\") -Replace [Regex]::Escape($Source), $Dest
  6. If(!(Test-Path $Path)){
  7. New-Item -ItemType Directory -Path $Path -Force | Out-Null
  8. Copy-Item $_.FullName -Destination $Path -Force
  9. }
  10. }
  11.  
  12.  
  13. $ZIP = "C:\Program Files\7-Zip\7z.exe"
  14.  
  15. $allCompressedFiles_gz = Get-ChildItem -Path C:\Temp\MS -Recurse -File
  16. foreach ($gzFile in $allCompressedFiles_gz) {
  17.  
  18. $filePath = Split-Path -Path $gzFile.FullName -Parent -Resolve
  19. $fileName = Split-Path -Path $gzFile.FullName -Leaf -Resolve
  20. Write-Host $fileName
  21. #$filePath = (get-item ($gzFile.FullName) ).parent.Parent
  22. #write-host $filePath
  23. set-location -Path $filePath
  24. if ( $fileName -like "*gz" ) {
  25. & $ZIP e $fileName
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement