Created
August 29, 2016 16:06
-
-
Save johnt1000/455299c6e158adf02180a03f711e2723 to your computer and use it in GitHub Desktop.
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
This might work for you: | |
# mkdir temp && cd temp && touch file.{a..e} | |
# ls | |
file.a file.b file.c file.d file.e | |
# md5sum * | sed -e 's/\([^ ]*\) \(.*\(\..*\)\)$/mv -v \2 \1\3/' | sh | |
`file.a' -> `d41d8cd98f00b204e9800998ecf8427e.a' | |
`file.b' -> `d41d8cd98f00b204e9800998ecf8427e.b' | |
`file.c' -> `d41d8cd98f00b204e9800998ecf8427e.c' | |
`file.d' -> `d41d8cd98f00b204e9800998ecf8427e.d' | |
`file.e' -> `d41d8cd98f00b204e9800998ecf8427e.e' | |
Or GNU sed can do it even shorter: | |
# md5sum * | sed -e 's/\([^ ]*\) \(.*\(\..*\)\)$/mv -v \2 \1\3/e' | |
The Apple/OSX version is: md5 * | sed -e 's/MD5 (\([^.]*\)\(.[^)]*\)) = \(.*\)$/mv -v "\1\2" \3\2/' | sh – fnl | |
http://stackoverflow.com/questions/8201729/rename-files-to-md5-sum-extension-bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment