For example, I have several png files named in the form of dataCounts_*_g.png, and I want to mv them into the form of *_g_f.png. All I have to do is to delete the ``dataCounts_'' part and insert ``_f'' into ``_g.png.''
Because I don't need to change all the filenames under the working directory, it is not necessary to use find. Using ls is enough.
Furthermore, I need to change more than one part of the original files, so I apply the substituting function of sed twice. Finally I have the commands as the follows.
ls *.png | sed -e p -e 's/dataCounts_//' -e 's/_g/_g_f/' | xargs -n2 mv
No comments:
Post a Comment