Skip to content

Instantly share code, notes, and snippets.

@oukishu
oukishu / RenameByHash.ps1
Last active April 20, 2026 11:54
This script renames files to the last 10 uppercase characters of their SHA256 hash, with automatic collision handling (12-char fallback or numeric suffixes).
# Example Command: .\RenameByHash.ps1 -TargetDir "[Path]" -Extension "[FileSuffix]"
# Define parameters that can be passed via command line
param(
[string]$TargetDir,
[string]$Extension
)
# If TargetDir wasn't provided as an argument, ask for it
if ([string]::IsNullOrWhiteSpace($TargetDir)) {
$TargetDir = Read-Host "Enter target folder path (Press Enter for current directory)"