I have 3 directories on my Ubuntu machine, named `abc`, `xyz` and `pst`. In each directory, I have approximately 7 files with different names. I want to rename each file like `abc_1.txt`, `abc_2.txt`, `abc_3.txt`, `abc_4.txt`, `abc_5.txt`, `abc_6.txt`, `abc_7.txt`. Similarly, with the `xyz` and `pst` directories. 

To clarify, I tried one of the answers below:

```
i=0
for f in */* ; do i=$(( i+1 )) fp=$(dirname "$f"); ext="${f##*.}" ; echo "$f" "$fp"/"$fp"_"$i"."$ext" ;done

```

And the output is:

```
123/1.jpg 123/123_1.jpg
123/2.jpg 123/123_2.jpg
123/3.jpg 123/123_3.jpg
2275/2275_1.jpg 2275/2275_4.jpg
2275/2275_2.jpg 2275/2275_5.jpg
2275/2275_3.jpg 2275/2275_6.jpg
2275/2275_4.jpg 2275/2275_7.jpg
2275/2275_5.jpg 2275/2275_8.jpg
2275/2275_6.jpg 2275/2275_9.jpg
2275/2275_7.jpg 2275/2275_10.jpg
2275/2275_Thumbs.db 2275/2275_11.db
456/1.jpg 456/456_12.jpg
456/2.jpg 456/456_13.jpg
456/3.jpg 456/456_14.jpg

```

But I want the result to be like this:

```
123/1.jpg 123/123_1.jpg
123/2.jpg 123/123_2.jpg
123/3.jpg 123/123_3.jpg
2275/2275_1.jpg 2275/2275_1.jpg
2275/2275_2.jpg 2275/2275_2.jpg
2275/2275_3.jpg 2275/2275_3.jpg
2275/2275_4.jpg 2275/2275_4.jpg
2275/2275_5.jpg 2275/2275_5.jpg
2275/2275_6.jpg 2275/2275_6.jpg
2275/2275_7.jpg 2275/2275_7.jpg
2275/2275_Thumbs.db 2275/2275_8.db
456/1.jpg 456/456_1.jpg
456/2.jpg 456/456_2.jpg
456/3.jpg 456/456_3.jpg

```

How can I do this?