Reputation: 141
I saw how to rename many files at once and changing their extensions, like this example
$ rename -v 's/\.htm$/\.html/' *.htm
3.htm renamed as 3.html
4.htm renamed as 4.html
5.htm renamed as 5.html
The only problem as you know in Linux, it doesn't need extensions, so my files are without them and want to add jpg extension to them at the same time giving them random number name like 0.jpg, 1.jpg ...
If you could give me a simple bash command to do it and thank you.
Upvotes: 3
Views: 148
Reputation: 67567
random file names may have overlaps, if you want use sequential numbers you can try something like this (assuming the files are in the current directory)
$ touch some files without extensions
$ ls
extensions files some without
$ i=0; for f in *; do mv ${f} $((i=++i)).ext; done
$ ls
1.ext 2.ext 3.ext 4.ext
Upvotes: 2