Created
October 4, 2025 03:11
-
-
Save onyx-nxt/017343c2ed4ec8f45804bc3dbacf3295 to your computer and use it in GitHub Desktop.
Converts Android's screenshot filename format (Screenshot_YYYYMMDD_HHMMSS_AppName) to match the Windows Snipping Tool format (Screenshot YYYY-MM-DD HHMMSS) while preserving file timestamps.
This file contains hidden or 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
| $folderPath = "C:\Path\To\Directory" | |
| # Process matching screenshot files | |
| Get-ChildItem -Path $folderPath -Filter "Screenshot_*.png" | ForEach-Object { | |
| $fileName = $_.BaseName | |
| # Match Screenshot_YYYYMMDD_HHMMSS and extract timestamp | |
| if ($fileName -match '^Screenshot_(\d{8})_(\d{6})') { | |
| $date = $matches[1] | |
| $time = $matches[2] | |
| $year = $date.Substring(0,4) | |
| $month = $date.Substring(4,2) | |
| $day = $date.Substring(6,2) | |
| $hour = $time.Substring(0,2) | |
| $minute = $time.Substring(2,2) | |
| $second = $time.Substring(4,2) | |
| $timestamp = Get-Date -Year $year -Month $month -Day $day -Hour $hour -Minute $minute -Second $second | |
| # Format: Screenshot YYYY-MM-DD HHMMSS.png | |
| $newName = "Screenshot {0}-{1}-{2} {3}.png" -f ` | |
| $year, ` | |
| $month, ` | |
| $day, ` | |
| $time ` | |
| $newFilePath = Join-Path $folderPath $newName | |
| # Rename the file | |
| Rename-Item -Path $_.FullName -NewName $newName | |
| $newFile = Get-Item -Path $newFilePath | |
| # Apply timestamps | |
| $newFile.CreationTime = $timestamp | |
| $newFile.LastWriteTime = $timestamp | |
| Write-Host "`e[32mRenamed: $($_.Name) → $newName`e[0m" | |
| Write-Host "`e[32mUpdated timestamps for: $($_.Name) → $timestamp`e[0m" | |
| } else { | |
| Write-Host "`e[31mSkipped: $($_.Name) (Invalid format)`e[0m" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment