awk -F, ‘NR>1&&2==1{print2==1{print 1}’ submission_model_1_v1.csv | xargs mv –target-directory=result_1
上面通过 xagrs 把所有的图片通过参数,然后 mv到target directory中
或者(下面是移动文件并按照 0000x.jpg格式化重命名)
find -name ‘*.jpg’ # find jpg s
| awk ‘BEGIN{ a=0 }{ printf “mv ”%s” %04d.jpg
”, $0, a++ }’ # build mv command
| bash # run that command
文件批量重命名
比如我要把目录下所有的 png->jpg
rename 's/.png$/.jpg/' *.png
# 或者
for file in *.png
do
mv "$file" "${file%.png}.jpg"
done
又比如想按照 0001~0010 ,jpg 这样的形式命名可以
find -name '*.jpg' # find png s
| awk 'BEGIN{ a=0 }{ printf "mv "%s" %04d.jpg
", $0, a++ }' # build mv command
| bash # run that command