按时间的创建/修改顺序重命名文件

#!/bin/bash

index=1
for i in `ls -U *.mp4`; do
    new=$(printf "%02d.${i}" ${index})
    mv ${i} ${new}
    let index=index+1
done

-t 按最后修改时间
-U 按创建时间

$ man ls
-t      Sort by time modified (most recently modified first) before sorting the operands by lexicographical order.
-U      Use time of file creation, instead of last modification for sorting (-t) or long output (-l).

你可能感兴趣的:(按时间的创建/修改顺序重命名文件)