Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. function DeleteSourceFiles($srcPath) {
  2. # Announce delete
  3. OutputToHostAndLog ("Files will be removed from "+$srcPath+"...")
  4. OutputToHostAndLog "Removing files..."
  5.  
  6. # Deletes all file items (i.e. all except folders) in source folder
  7. $filesToDelete=Get-ChildItem $srcPath | Where-Object {$_ -is [IO.FileInfo]}
  8. ForEach($item in $filesToDelete) {
  9. Remove-Item $srcPath$item -force
  10.  
  11. # Verify deletions
  12. if(Test-Path($srcPath+""+$item)) {
  13. OutputToHostAndLog ("Delete failed: "+$item.Name)
  14. $fail++
  15. }
  16. else {
  17. OutputToHostAndLog ($item.Name+" deleted successfully...")
  18. }
  19. }
  20. }
  21.  
  22. function DeleteSourceFiles($srcPath) {
  23. # Announce delete
  24. OutputToHostAndLog ("Files will be removed from "+$srcPath+"...")
  25. OutputToHostAndLog "Removing files..."
  26. OutputToHostAndLog $gap
  27.  
  28. # Delete all file items (i.e. all except folders) in source folder
  29. $filesToDelete=Get-ChildItem $srcPath | Where-Object {$_ -is [IO.FileInfo]} | ForEach {
  30. Remove-Item $_.FullName -Force
  31.  
  32. # Verify deletions
  33. if(Test-Path($srcPath+""+$_)) {
  34. OutputToHostAndLog ("Delete failed: "+$_.Name)
  35. $fail++
  36. }
  37. else {
  38. OutputToHostAndLog ($_.Name+" deleted successfully...")
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement