Returning the MD5-hash of all files in a directory to a .txt file with file name
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have a directory of pictures.
I need the MD5-hash of each file in that directory and the name of the file placed into a .txt
document. This file is to be read at a later time to reference the MD5 and file name together.
Note:
I would like this to just pull all directory files with me specifying them.
I have tried playing with tar
and find
and I just cannot seem to find a good solution...
This is a directory example:
/Desktop/testing
RandomFilename1.png
RandomFilename2.png
RandomFilename3.png
The .txt
output is:
RandomFilename1,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename2,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename3,da39a3ee5e6b4b0d3255bfef95601890afd80709
I've looked everywhere online with no luck.
This will be on a Linux terminal.
command-line find md5sum
New contributor
add a comment |Â
up vote
2
down vote
favorite
I have a directory of pictures.
I need the MD5-hash of each file in that directory and the name of the file placed into a .txt
document. This file is to be read at a later time to reference the MD5 and file name together.
Note:
I would like this to just pull all directory files with me specifying them.
I have tried playing with tar
and find
and I just cannot seem to find a good solution...
This is a directory example:
/Desktop/testing
RandomFilename1.png
RandomFilename2.png
RandomFilename3.png
The .txt
output is:
RandomFilename1,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename2,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename3,da39a3ee5e6b4b0d3255bfef95601890afd80709
I've looked everywhere online with no luck.
This will be on a Linux terminal.
command-line find md5sum
New contributor
Do you really want the file names without the extension in the output? If so, what if two file names only differ in their extension?
â dessert
29 mins ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have a directory of pictures.
I need the MD5-hash of each file in that directory and the name of the file placed into a .txt
document. This file is to be read at a later time to reference the MD5 and file name together.
Note:
I would like this to just pull all directory files with me specifying them.
I have tried playing with tar
and find
and I just cannot seem to find a good solution...
This is a directory example:
/Desktop/testing
RandomFilename1.png
RandomFilename2.png
RandomFilename3.png
The .txt
output is:
RandomFilename1,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename2,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename3,da39a3ee5e6b4b0d3255bfef95601890afd80709
I've looked everywhere online with no luck.
This will be on a Linux terminal.
command-line find md5sum
New contributor
I have a directory of pictures.
I need the MD5-hash of each file in that directory and the name of the file placed into a .txt
document. This file is to be read at a later time to reference the MD5 and file name together.
Note:
I would like this to just pull all directory files with me specifying them.
I have tried playing with tar
and find
and I just cannot seem to find a good solution...
This is a directory example:
/Desktop/testing
RandomFilename1.png
RandomFilename2.png
RandomFilename3.png
The .txt
output is:
RandomFilename1,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename2,da39a3ee5e6b4b0d3255bfef95601890afd80709
RandomFilename3,da39a3ee5e6b4b0d3255bfef95601890afd80709
I've looked everywhere online with no luck.
This will be on a Linux terminal.
command-line find md5sum
command-line find md5sum
New contributor
New contributor
edited 59 mins ago
muru
133k19280478
133k19280478
New contributor
asked 3 hours ago
Grayson Moseley
111
111
New contributor
New contributor
Do you really want the file names without the extension in the output? If so, what if two file names only differ in their extension?
â dessert
29 mins ago
add a comment |Â
Do you really want the file names without the extension in the output? If so, what if two file names only differ in their extension?
â dessert
29 mins ago
Do you really want the file names without the extension in the output? If so, what if two file names only differ in their extension?
â dessert
29 mins ago
Do you really want the file names without the extension in the output? If so, what if two file names only differ in their extension?
â dessert
29 mins ago
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
2
down vote
You can use the following bash
command:
for file in testing/*; do md5sum $file; done > res.txt
Of course you have to adjust the destination directory of res.txt
.
The result could look similar to this:
8b1500ea6fe42927891fd1831bb955ba testing/Pic1.gif
73f3222889a14411a3b78675ed0bc269 testing/Pic2.gif
c5b18ef1ea1346f13f668a7ead4e4c92 testing/Pic3.gif
So the MD5 hash is followed by the filename and path.
4
The benefit of this solution is that you can later check the md5's withmd5sum -c res.txt
. I'd also suggest a simplemd5sum *.gif > res.txt
instead of a loop.
â PerlDuck
2 hours ago
Also, you should move the redirect outside the loop:for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.
â muru
57 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
add a comment |Â
up vote
1
down vote
For what you want to do, execute md5sum
and use sed
or awk
to transform the output
md5sum *.png | sed 's/^([0-9a-f]+) +(.+)/2,1/' >images.md5sums
md5sum *.png | awk 'print $2","$1' >image.md5sums
However, the plain output of md5sum
is hash filename
and is equivalent to your format. Using that standard md5sum
output format is often more convenient, since you can use it directly with md5sum -c
to check the hash of the files (after a copy or network transfer). Some other utilities may also expect this particular format.
add a comment |Â
up vote
-1
down vote
I have written a small script as per the parameters defined:
cd /home/username/Desktop/testing
for F in *
do
echo $F, $(md5sum $F | tr --delete $F)
done
Example output:
1.txt, c8ef7cca2ceb3f87892bff63dbf9
demo, 9470a3c74b32036fa148fabc70929
line.cpp, 0732d27816b2b57d413f79f91fd28
test, 37346996108d322767cf65f90d43c
test.cpp, afb5b90f0021b6df4f98df40
Note: This script would show the output in terminal. To save it in file you can use > 1.txt
while executing the file, for e.g.:
./test.sh > 1.txt
You want to quote more, e.g.md5sum $F
will throw errors in case of file names with spaces in it.
â dessert
32 mins ago
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
You can use the following bash
command:
for file in testing/*; do md5sum $file; done > res.txt
Of course you have to adjust the destination directory of res.txt
.
The result could look similar to this:
8b1500ea6fe42927891fd1831bb955ba testing/Pic1.gif
73f3222889a14411a3b78675ed0bc269 testing/Pic2.gif
c5b18ef1ea1346f13f668a7ead4e4c92 testing/Pic3.gif
So the MD5 hash is followed by the filename and path.
4
The benefit of this solution is that you can later check the md5's withmd5sum -c res.txt
. I'd also suggest a simplemd5sum *.gif > res.txt
instead of a loop.
â PerlDuck
2 hours ago
Also, you should move the redirect outside the loop:for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.
â muru
57 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
add a comment |Â
up vote
2
down vote
You can use the following bash
command:
for file in testing/*; do md5sum $file; done > res.txt
Of course you have to adjust the destination directory of res.txt
.
The result could look similar to this:
8b1500ea6fe42927891fd1831bb955ba testing/Pic1.gif
73f3222889a14411a3b78675ed0bc269 testing/Pic2.gif
c5b18ef1ea1346f13f668a7ead4e4c92 testing/Pic3.gif
So the MD5 hash is followed by the filename and path.
4
The benefit of this solution is that you can later check the md5's withmd5sum -c res.txt
. I'd also suggest a simplemd5sum *.gif > res.txt
instead of a loop.
â PerlDuck
2 hours ago
Also, you should move the redirect outside the loop:for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.
â muru
57 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
You can use the following bash
command:
for file in testing/*; do md5sum $file; done > res.txt
Of course you have to adjust the destination directory of res.txt
.
The result could look similar to this:
8b1500ea6fe42927891fd1831bb955ba testing/Pic1.gif
73f3222889a14411a3b78675ed0bc269 testing/Pic2.gif
c5b18ef1ea1346f13f668a7ead4e4c92 testing/Pic3.gif
So the MD5 hash is followed by the filename and path.
You can use the following bash
command:
for file in testing/*; do md5sum $file; done > res.txt
Of course you have to adjust the destination directory of res.txt
.
The result could look similar to this:
8b1500ea6fe42927891fd1831bb955ba testing/Pic1.gif
73f3222889a14411a3b78675ed0bc269 testing/Pic2.gif
c5b18ef1ea1346f13f668a7ead4e4c92 testing/Pic3.gif
So the MD5 hash is followed by the filename and path.
edited 34 mins ago
dessert
20.7k55896
20.7k55896
answered 3 hours ago
zx485
1,33521114
1,33521114
4
The benefit of this solution is that you can later check the md5's withmd5sum -c res.txt
. I'd also suggest a simplemd5sum *.gif > res.txt
instead of a loop.
â PerlDuck
2 hours ago
Also, you should move the redirect outside the loop:for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.
â muru
57 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
add a comment |Â
4
The benefit of this solution is that you can later check the md5's withmd5sum -c res.txt
. I'd also suggest a simplemd5sum *.gif > res.txt
instead of a loop.
â PerlDuck
2 hours ago
Also, you should move the redirect outside the loop:for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.
â muru
57 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
4
4
The benefit of this solution is that you can later check the md5's with
md5sum -c res.txt
. I'd also suggest a simple md5sum *.gif > res.txt
instead of a loop.â PerlDuck
2 hours ago
The benefit of this solution is that you can later check the md5's with
md5sum -c res.txt
. I'd also suggest a simple md5sum *.gif > res.txt
instead of a loop.â PerlDuck
2 hours ago
Also, you should move the redirect outside the loop:
for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.â muru
57 mins ago
Also, you should move the redirect outside the loop:
for file ... done > res.txt
, instead of opening and closing that file for each run of the loop.â muru
57 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
@muru: Thanks for your suggestion.
â zx485
53 mins ago
add a comment |Â
up vote
1
down vote
For what you want to do, execute md5sum
and use sed
or awk
to transform the output
md5sum *.png | sed 's/^([0-9a-f]+) +(.+)/2,1/' >images.md5sums
md5sum *.png | awk 'print $2","$1' >image.md5sums
However, the plain output of md5sum
is hash filename
and is equivalent to your format. Using that standard md5sum
output format is often more convenient, since you can use it directly with md5sum -c
to check the hash of the files (after a copy or network transfer). Some other utilities may also expect this particular format.
add a comment |Â
up vote
1
down vote
For what you want to do, execute md5sum
and use sed
or awk
to transform the output
md5sum *.png | sed 's/^([0-9a-f]+) +(.+)/2,1/' >images.md5sums
md5sum *.png | awk 'print $2","$1' >image.md5sums
However, the plain output of md5sum
is hash filename
and is equivalent to your format. Using that standard md5sum
output format is often more convenient, since you can use it directly with md5sum -c
to check the hash of the files (after a copy or network transfer). Some other utilities may also expect this particular format.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
For what you want to do, execute md5sum
and use sed
or awk
to transform the output
md5sum *.png | sed 's/^([0-9a-f]+) +(.+)/2,1/' >images.md5sums
md5sum *.png | awk 'print $2","$1' >image.md5sums
However, the plain output of md5sum
is hash filename
and is equivalent to your format. Using that standard md5sum
output format is often more convenient, since you can use it directly with md5sum -c
to check the hash of the files (after a copy or network transfer). Some other utilities may also expect this particular format.
For what you want to do, execute md5sum
and use sed
or awk
to transform the output
md5sum *.png | sed 's/^([0-9a-f]+) +(.+)/2,1/' >images.md5sums
md5sum *.png | awk 'print $2","$1' >image.md5sums
However, the plain output of md5sum
is hash filename
and is equivalent to your format. Using that standard md5sum
output format is often more convenient, since you can use it directly with md5sum -c
to check the hash of the files (after a copy or network transfer). Some other utilities may also expect this particular format.
edited 34 mins ago
dessert
20.7k55896
20.7k55896
answered 1 hour ago
xenoid
1,2861314
1,2861314
add a comment |Â
add a comment |Â
up vote
-1
down vote
I have written a small script as per the parameters defined:
cd /home/username/Desktop/testing
for F in *
do
echo $F, $(md5sum $F | tr --delete $F)
done
Example output:
1.txt, c8ef7cca2ceb3f87892bff63dbf9
demo, 9470a3c74b32036fa148fabc70929
line.cpp, 0732d27816b2b57d413f79f91fd28
test, 37346996108d322767cf65f90d43c
test.cpp, afb5b90f0021b6df4f98df40
Note: This script would show the output in terminal. To save it in file you can use > 1.txt
while executing the file, for e.g.:
./test.sh > 1.txt
You want to quote more, e.g.md5sum $F
will throw errors in case of file names with spaces in it.
â dessert
32 mins ago
add a comment |Â
up vote
-1
down vote
I have written a small script as per the parameters defined:
cd /home/username/Desktop/testing
for F in *
do
echo $F, $(md5sum $F | tr --delete $F)
done
Example output:
1.txt, c8ef7cca2ceb3f87892bff63dbf9
demo, 9470a3c74b32036fa148fabc70929
line.cpp, 0732d27816b2b57d413f79f91fd28
test, 37346996108d322767cf65f90d43c
test.cpp, afb5b90f0021b6df4f98df40
Note: This script would show the output in terminal. To save it in file you can use > 1.txt
while executing the file, for e.g.:
./test.sh > 1.txt
You want to quote more, e.g.md5sum $F
will throw errors in case of file names with spaces in it.
â dessert
32 mins ago
add a comment |Â
up vote
-1
down vote
up vote
-1
down vote
I have written a small script as per the parameters defined:
cd /home/username/Desktop/testing
for F in *
do
echo $F, $(md5sum $F | tr --delete $F)
done
Example output:
1.txt, c8ef7cca2ceb3f87892bff63dbf9
demo, 9470a3c74b32036fa148fabc70929
line.cpp, 0732d27816b2b57d413f79f91fd28
test, 37346996108d322767cf65f90d43c
test.cpp, afb5b90f0021b6df4f98df40
Note: This script would show the output in terminal. To save it in file you can use > 1.txt
while executing the file, for e.g.:
./test.sh > 1.txt
I have written a small script as per the parameters defined:
cd /home/username/Desktop/testing
for F in *
do
echo $F, $(md5sum $F | tr --delete $F)
done
Example output:
1.txt, c8ef7cca2ceb3f87892bff63dbf9
demo, 9470a3c74b32036fa148fabc70929
line.cpp, 0732d27816b2b57d413f79f91fd28
test, 37346996108d322767cf65f90d43c
test.cpp, afb5b90f0021b6df4f98df40
Note: This script would show the output in terminal. To save it in file you can use > 1.txt
while executing the file, for e.g.:
./test.sh > 1.txt
edited 33 mins ago
dessert
20.7k55896
20.7k55896
answered 3 hours ago
Kulfy
2,0592831
2,0592831
You want to quote more, e.g.md5sum $F
will throw errors in case of file names with spaces in it.
â dessert
32 mins ago
add a comment |Â
You want to quote more, e.g.md5sum $F
will throw errors in case of file names with spaces in it.
â dessert
32 mins ago
You want to quote more, e.g.
md5sum $F
will throw errors in case of file names with spaces in it.â dessert
32 mins ago
You want to quote more, e.g.
md5sum $F
will throw errors in case of file names with spaces in it.â dessert
32 mins ago
add a comment |Â
Grayson Moseley is a new contributor. Be nice, and check out our Code of Conduct.
Grayson Moseley is a new contributor. Be nice, and check out our Code of Conduct.
Grayson Moseley is a new contributor. Be nice, and check out our Code of Conduct.
Grayson Moseley is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1090582%2freturning-the-md5-hash-of-all-files-in-a-directory-to-a-txt-file-with-file-name%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Do you really want the file names without the extension in the output? If so, what if two file names only differ in their extension?
â dessert
29 mins ago