-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpowershell.ps1
29 lines (27 loc) · 981 Bytes
/
powershell.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Add-Type -AssemblyName System.Drawing
function ResizeImage {
param (
[string]$sourcePath,
[string]$targetPathBase,
[int[]]$targetResolutions
)
foreach ($targetResolution in $targetResolutions) {
$image = [System.Drawing.Image]::FromFile($sourcePath)
$newImage = $image.GetThumbnailImage($targetResolution, $targetResolution, $null, [System.IntPtr]::Zero)
$targetPath = $targetPathBase + "_$targetResolution" + "x" + "$targetResolution.png"
$newImage.Save($targetPath, [System.Drawing.Imaging.ImageFormat]::Png)
$image.Dispose()
$newImage.Dispose()
}
}
function Rename {
param (
[string]$prefix,
[string]$newPrefix
)
$files = Get-ChildItem -Path . -File -Filter "$prefix*" -Recurse
foreach ($file in $files) {
$newFileName = $file.FullName -replace $prefix, $newPrefix
Move-Item -Path $file.FullName -Destination $newFileName -Force
}
}