I am new to bash loops and trying to rename all files in a directory to their appropriate md5 values.

There are 5 sample files in the directory.
For testing purpose, I am trying to first just print md5 hashes of all files in the directory using below command and it is working fine.

```
for i in `ls`; do md5sum $i; done 

```

Output:

```
edc47be8af3a7d4d55402ebae9f04f0a  file1
72cf1321d5f3d2e9e1be8abd971f42f5  file2
4b7b590d6d522f6da7e3a9d12d622a07  file3
357af1e7f8141581361ac5d39efa4d89  file4
1445c4c1fb27abd9061ada3b30a18b44  file5

```

Now I am trying to rename each file with its appropriate md5 hashes by following command:

```
for i in `ls`; do mv $i md5sum $i; done

```

Failed Output:

```
mv: target 'file1' is not a directory
mv: target 'file2' is not a directory
mv: target 'file3' is not a directory
mv: target 'file4' is not a directory
mv: target 'file5' is not a directory

```

What am I missing here?