Last active
May 29, 2022 13:40
-
-
Save mono0x/6ac8af8f4e6b57e601d0b8ac19141e12 to your computer and use it in GitHub Desktop.
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
$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