Skip to content

Instantly share code, notes, and snippets.

@mono0x
Last active May 29, 2022 13:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mono0x/6ac8af8f4e6b57e601d0b8ac19141e12 to your computer and use it in GitHub Desktop.
Save mono0x/6ac8af8f4e6b57e601d0b8ac19141e12 to your computer and use it in GitHub Desktop.
$ErrorActionPreference = 'Stop'
foreach ($file in ($args | ForEach-Object { Get-Item $_ } | Sort-Object -Property FullName)) {
if ($file.Name -match '\A\d{8}-\d{6}-') {
# Already renamed (Skip)
continue
}
$timeOptions = if ($file.Name.ToUpper().StartsWith("GX")) {
# GoPro (Shift time zone)
@('-GlobalTimeShift', '-9')
}
else {
# Default
@()
}
$argFile = New-TemporaryFile # Create an argfile to handle Unicode filename correctly.
try {
Out-File -Encoding UTF8 -FilePath $argFile.FullName -InputObject $file.FullName
exiftool.exe -api largefilesupport=1 '-FileName<CreateDate' -charset FileName=UTF8 -d '%Y%m%d-%H%M%S-%%f.%%e' -api QuickTimeUTC @timeOptions -@ $argFile.FullName
}
finally {
Remove-Item $argFile.FullName
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment