Last active
February 27, 2024 11:46
-
-
Save SanSan-/751e955a1b1e5d881d873a493fe4f34d to your computer and use it in GitHub Desktop.
In current dir rename all img with selected extension to they hash-code
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
$Algo = "MACTripleDES" | |
$current = Get-Location | |
if ($args[0] -ne $null) { | |
$Ext = $args[0] | |
} else { | |
$Ext = ".png" | |
} | |
$files = Get-ChildItem -Path $current.Path -Recurse | Where-Object {$_.Extension -eq $Ext} | |
Write-Output $files | |
foreach ($file in $files) | |
{ | |
$fullFileName = $file.FullName | |
$fileHash = Get-FileHash -Path $fullFileName -Algorithm $Algo | |
$newHash = $fileHash.Hash | |
$newFileName = "$newHash$Ext" | |
Rename-Item -Path $fullFileName -NewName $newFileName | |
Write-Output "Rename $newFileName complete!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment