#!/bin/sh noofdirs=$(find . -mindepth 1 -maxdepth 1 -type d | wc -l) lenofnod=$(echo -n "$noofdirs" | wc -m) ## Flag n to prevent newline count ls -vtr | nl -w$lenofnod -s ". " -n rz | while read n f; do mv -n "$f" "$n $f" ; done