2012-10-31

Today's Oneliner: Numbering Files

mkdir renamed
ls -1 *(.) | sort | awk '{ count++; printf "cp %s renamed/%04d\n",$1,count; }' | zsh
  1. get the list of files in the current directory
  2. sort the list with sort command by the required order: reversed, numeric, ignoring case, ...
  3. generate a shell script, and execute it.

0 件のコメント:

コメントを投稿