PowerShell: Rename File to Hash
This script rename all files in a dir into the file content's hash values.
This is useful when you have downloaded thousands of image files on the internet, and want to make sure you don't have duplicates.
Sample file name:
005662EE35110980CEDC1E5B1CD0E23B329C394A65E9134B2EBD0EAE3EC09DC3.jpg
$mydir = "~/Downloads/million_images/"; dir $mydir -file | ForEach-Object { $ext = Split-Path -Extension $_; $newname = (Get-FileHash $_).hash + $ext; Rename-Item $_.fullname $newname }