Batch renaming files in command line and Xargs

后端 未结 9 749
余生分开走
余生分开走 2020-12-12 16:32

So, I have the following structure:

.
..
a.png
b.png 
c.png

I ran a command to resize them

ls | xargs -I xx convert xx -res         


        
9条回答
  •  孤街浪徒
    2020-12-12 17:11

    find ./xx -name "*.png" -print0 |sed 's/.png$//g'|xargs -0 -I% mv %.png %.jpg

    I like to use following command

    find ./xx -name "*.png" -type f|while read FILE; do
      mv "$FILE" "$(echo $FILE|sed -e 's/.png$/.jpg/')";
    done
    

提交回复
热议问题