Skip to content

Instantly share code, notes, and snippets.

@SteveGilham
Last active January 28, 2024 16:01
Show Gist options
  • Save SteveGilham/a92ee63c4c37b1ad333dd262d7081256 to your computer and use it in GitHub Desktop.
Save SteveGilham/a92ee63c4c37b1ad333dd262d7081256 to your computer and use it in GitHub Desktop.
Using exiftool to add the prompt to a Bing Image Creator download
<#
.SYNOPSIS
Using exiftool to add the prompt to a Bing Image Creator download.
.DESCRIPTION
Use like
& '.\OneDrive\Pictures\aigen\prompt.ps1' "minimalist style corporate flower logo. simple, clean, uncluttered, modern, elegant"
or
& '.\OneDrive\Pictures\aigen\prompt.ps1' -prompt "minimalist style corporate flower logo. simple, clean, uncluttered, modern, elegant"
to add the prompt
.NOTES
File Name : Prompt.ps1
Requires : PowerShell Version 2.0
.PARAMETER Prompt
The string you passed to Bing, quoted and, as needs be, escaped e.g. for quotation marks
#>
param([String]$prompt="")
# use like
#
#
#
#
try {
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
}
catch {
# The first time in ISE we get an "invalid handle". Write something with -VER and try again.
exiftool -VER
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
}
# Set Working directory.
$save = Get-location
Set-Location "$($env:OneDrive)\Pictures\aigen"
dir "$($env:OneDrive)\..\downloads\_*.jpg" | % {
$newname = "bing$($_.CreationTime.ToUniversalTime().ToString("yyMMdd-HHmmss_ffff")).jpg"
mv $_ "$($env:OneDrive)\Pictures\aigen\$($newname)"
& "$($env:OneDrive)\Documents\exif\exiftool.exe" -echo4 `{ready18`} -CHARSET FILENAME=UTF8 -CHARSET UTF8 -v0 -overwrite_original -sep * -c %.6f° -API WindowsWideFile=1 "-exif:artist=$($prompt)" $newname -execute18 2>&1 | %{"$_"}
}
Set-Location $save
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment