批量重命名与IDS完整文件 [英] batch rename files with ids intact

查看:174
本文介绍了批量重命名与IDS完整文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样

seascaperecovered0088crop.jpg 
seascaperecovered0096crop.jpg
seascaperecovered0098crop.jpg
seascaperecovered0101crop.jpg
seascaperecovered0103crop.jpg
seascaperecovered0105crop.jpg
seascaperecovered0107crop.jpg
seascaperecovered0112crop.jpg
seascaperecovered0119crop.jpg
seascaperecovered0122crop.jpg

和我要重新命名所有的文件在这里看到:

and i want to rename all files as seen here:

seascape_0122.jpg

我已经试过这样的事情:

i have tried something like this:

for f in `ls | egrep 'seascaperecovered.*\.jpg'`; 
do mv $f ${f/seascaperecovered/seascape}; 
done

我已阅读,你可以用MV做到这一点,重命名,用sed,awk中,等等。
可有人点我在UNIX实现这个最简单的(和最清晰的,希望如此)的方式?
FWIW,我SSH方式登录一台Linux机器和运行bash shell的。

i have read that you can do this with mv, rename, sed, awk, etc. can someone point me to the easiest (and clearest, hopefully) way of accomplishing this in UNIX? FWIW, I am ssh'd into a Linux machine and running a bash shell.

谢谢,
JML

thanks, jml

推荐答案

非常简单:

for i in seascaperecovered*.jpg; do A=${i/crop/}; mv $i ${A/recovered/_}; done

(把回声 MV之前第一个预演。)

这篇关于批量重命名与IDS完整文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆