简体   繁体   中英

Rename files to md5 sum + extension on Windows 7 (with CMD or PowerShell 2013)

I'm struggling to come up with a solution. All so far have been crutches since I cannot get my tools only to output the plain md5 string, to write it into a variable 2 and use it later on to rename the file I stored in a variable 1.

The solutions I found are for *nix or PHP and were not helpful with my problem.

You didn't write what you've already got, so I won't explain the script. Just remember that you'll get an error for files with same md5.

Get-ChildItem d:\temp\*.xxx | select FullName, Extension, @{name='md5'; expression={(Get-FileHash $_ -Algorithm md5).Hash}} | foreach {Rename-Item $_.FullName -NewName "$($_.md5)$($_.extension)"}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM