Created
May 17, 2021 06:23
-
-
Save mawiseman/ade75fcfcf571e7807e2a03849c1e961 to your computer and use it in GitHub Desktop.
Create a quick html page displaying all images under the target irectory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get files to process | |
$sourcePath ="[[UPDATE WITH FOLDER PATH]]" | |
$sourceFiles = Get-ChildItem -Path $sourcePath -File -Recurse -Filter *.png | |
# | |
$currentFolder = "" | |
$generatedGalery = "" | |
ForEach ($sourceFile in $sourceFiles) | |
{ | |
# processing File | |
$processingFile = $sourceFile.FullName -replace [regex]::Escape($sourcePath), "" | |
$processingFolder = $processingFile -replace [regex]::Escape($sourceFile.Name), "" | |
if($currentFolder -ne $processingFolder) { | |
$currentFolder = $processingFolder | |
$generatedGalery += "<h2>$currentFolder</h2>"; | |
} | |
$generatedGalery += "<img src='$($sourceFile.FullName)' title='$($sourceFile.Name)' />" | |
} | |
$htmlReportTemplate = "<html><body>[[body]]</body></html>" | |
$htmlReportPath = Join-Path $sourcePath "gallery.html" | |
$htmlReportContent = $htmlReportTemplate -replace [regex]::Escape("[[body]]"), $generatedGalery | |
$htmlReportContent | Out-File -FilePath $htmlReportPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment