Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PowerShell by blah ( 17 years ago )
#Prompt to enter paths and resize info
$SourceDir = Read-Host -Prompt "Enter images source path (default is C:Images)"
$DestinationDir = Read-Host -Prompt "Enter images destination path (default is C:Images_Out)"
$ResizePercentage = Read-Host -Prompt "Enter the percentage of the original size for the images (default is 9)"

#Check for null variables and set defaults
if (!$SourceDir) {$SourceDir = "C:Images"}
if (!$DestinationDir) {$DestinationDir = "C:Images_Out"}
if (!$ResizePercentage) {$ResizePercentage = 9}

#Check for destination path.  If it doesn't exist create it.
if (!(test-path -path $DestinationDir)) {md $DestinationDir -type directory}

#Make the magic happen
push-location $SourceDir
dir $SourceDir |? {$_.name -like "*.jpg"} |% {Import-Bitmap -Path $_.name | resize-bitmap -percent $ResizePercentage | export-bitmap -path ($DestinationDir + "" + "t" + $_.name) -Format JPEG -Quality 70}
pop-location

#Rename all ".jpeg" extensions to ".jpg"
push-location $DestinationDir
dir *.jpeg |% { rename-item $_.name $_.name.replace(”.jpeg”,”.jpg”) }
pop-location

 

Revise this Paste

Your Name: Code Language: