Search code examples
linuxterminalbatch-rename

Renaming files in a folder (linux)


I have a different HTML files in a folder. How to rename the files so that they have the names of:

1.html
2.html
3.html
...


Solution

  • This can make it:

    i=1
    for file in /your/folder/*
    do
       mv $file ${i}.html
       i=$((i+1)) #((i++)) was giving errors (see comments)
    done
    

    It loops through all files in /your/folder and renames them according to the number $i that keeps increasing.