Advertisement
paradizelost

conversion rewrite

Mar 11th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function convert-file($source, $destination)
  2. {
  3.     try{
  4.    
  5.     $i = [System.Drawing.Image]::FromFile($File.FullName)
  6.     $i.Save("$t","$IMGType")
  7.     } catch{ Write-Host "Errored on converting $file.fullname"
  8.     } finally {
  9.     }
  10. }
  11. function cleanfile($oldfile, $newfile){
  12.     if( Test-Path  -Path $newfile){
  13.     Remove-Item $oldfile
  14.     }
  15. }
  16.  
  17. ForEach ($File in $Files) {
  18.     try{
  19.     $old = join-path $File.DirectoryName $File.BaseName
  20.     $new = $old+".$FTypeEnd"  
  21.     convert-file -source $old -destination $new
  22.     cleanfile -oldfile $old -newfile $new
  23.     }   catch   {
  24.     log-functionhere -message "Error on $file.fullname"
  25.     } finally{}
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement