Tuesday, April 6, 2010

Change names of multiple files in a shell

Example: change all files whose name starts with "kIM" to "kIM_partial" with the same file type (.doc->.doc, .mat->.mat)

1. ls kIM* > namelist
2. cat namelist | awk '{c=split($0, s, "."); print "mv "$0" "s[1]"_partial."s[2]""}' | sh

No comments:

Post a Comment