Last active
January 15, 2026 01:20
-
-
Save ZSendokame/88d0a720a017a9933cabd2e2537ac17a to your computer and use it in GitHub Desktop.
Rename all files on two depths to their MD5 hash and remove the originals.
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
| $path = $args[0] | |
| $files = (Get-ChildItem $path -File) | |
| foreach($file in $files){ | |
| $extension = $file.Extension | |
| $newName = (Get-FileHash -LiteralPath $file.FullName -Algorithm MD5).Hash.toLower() | |
| $directory = $file.Directory.FullName | |
| $newPath = "$directory\$newName$extension" | |
| if(-not ($file.FullName -eq $newPath)){ | |
| Move-Item -Force -LiteralPath $file.FullName -Destination $newPath | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment