-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConvert_TIF_2_PNG.ps1
32 lines (23 loc) · 1.02 KB
/
Convert_TIF_2_PNG.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
30
31
32
# PowerShell 7.x
# Set the parent path
$parentPath = "E:\ConneyUSBDrives\USB20FD"
# Get a list of child folders in the parent path
$childFolders = (Get-ChildItem -Path $parentPath -Directory)
# Output the list of child folders
foreach ($folder in $childFolders){
# Get all the TIF files in the directory
$tifFiles = (Get-ChildItem -Path $folder -Recurse -Filter *.tiff)
# Convert each TIF file to PNG format
foreach ($tifFile in $tifFiles) {
# Output the TIF file name
Write-Host "Deleting $tifFile"
# Load the TIF file using .NET Framework's System.Drawing.Bitmap class
$image = New-Object System.Drawing.Bitmap($tifFile.FullName)
# Save the image as PNG using the same filename, but with the .png extension
$pngFile = [System.IO.Path]::ChangeExtension($tifFile.FullName, ".png")
$image.Save($pngFile, [System.Drawing.Imaging.ImageFormat]::Png)
# Dispose of the Bitmap object
$image.Dispose()
}
Write-Host "Converted files in $folder"
}