Saturday 15 June 2013

variables - PowerShell: Rotate multiple image files and save them to a directory with new name -


I am very new in PowerShell (I just took one semester in our local college). I have a directory with many image files (.mff) that are constantly being updated and I have to write a script that will take these files, save them in a new directory, and "end 90-wd. Looking for a while and coming up with a small code that will rotate the image but I can not find it to save it in a new directory. Any help?

  If (test- Path J: \ cutright \ v90 \ import \ MV_N Est_PTX_copy} {Load image} ("System.Windows.Formas") foreach ($ in file (LS "J: \ cutlight \ v90 \ import \ mV_NET_ PTX_copy \ * .wmf")) {$ Convert file = new $ Image.Fullname $ Bitmap $ ConvertFile.Retate Flip ("Rotate90FlipNone") $ Newfilname = ($ file.fullname) $ ConvertFile.Save ($ newfilname, "wmf") $ file.Fullname}} and { Type-Host "path not found."}  

You're almost there, you just New file name is created properly Requires:

  if (test-path j: \ cutite \ v90 \ import \ mV_Nest_PTX_copy) {[Reflection.Assembly] :: LoadWithPartialName ("System.Windows Forms") foreach ($ ls "$ J: \ CutRite \ v90 \ import \ MV_Nest_PTX_copy \ *. Wmf ")) {$ ConvertFile = New Object.Digit.bitmap ($ file.Fullname) $ ConvertFile $ Rotateflip (" Rotate90FlipNone ") $ newfilename = $ file.Fullname.replace (" .wmf "," _ 90.wmf " ) $ Convert file. Save ($ newfilname)}}  

You can change .wmf to replace _90.wmf Use the $ newfilename method.> Variable, then save the image using that name.

In addition, it is not certain that you Why are loading System.Windows.Forms - unless you have a sni Do not use it in the inclu

update:

If you want to completely save to a different directory:

  $ newfilename =" C: \ path \ to \ new \ dir \ "+ $ file.name.replace (" .wmf "," _ 90.wmf ")  

No comments:

Post a Comment