>_ aalvz

← Blog · Cool-Code

Renaming enumerating

For a bunch of files, this code renames the file adding a number to the beginning of the filename.

In the terminal: cat cool_code/random


c=1; for file in `ls -Utp | grep -v / | awk '{ print $9 }' `; do mv "$file" "$[c++]"-"$file"; done