I need to convert all images in folder and subfolders to jpg. I need to batch this process with command file. GUI tools needles for me I need the script.
I tried to
I've done something similar with converting a bitmap files to icon files here:
http://sev17.com/2011/07/creating-icons-files/
I adapted it to your requirements and test a function for converting image files to jpg:
function ConvertTo-Jpg
{
[cmdletbinding()]
param([Parameter(Mandatory=$true, ValueFromPipeline = $true)] $Path)
process{
if ($Path -is [string])
{ $Path = get-childitem $Path }
$Path | foreach {
$image = [System.Drawing.Image]::FromFile($($_.FullName));
$FilePath = [IO.Path]::ChangeExtension($_.FullName, '.jpg');
$image.Save($FilePath, [System.Drawing.Imaging.ImageFormat]::Jpeg);
$image.Dispose();
}
}
}
#Use function:
#Cd to directory w/ png files
cd .\bin\pngTest
#Run ConvertTo-Jpg function
Get-ChildItem *.png | ConvertTo-Jpg