Chinaunix
标题:
关于linux shell的问题批量重命名
[打印本页]
作者:
sucbttp
时间:
2013-06-13 21:40
标题:
关于linux shell的问题批量重命名
您好,希望您帮帮我,关于linux shell的问题批量重命名,在网上找了一天的答案无果。麻烦您了。例如 有3个文件,都是没规律的名字,如“文件b、文件a、文件d”
我还有一个文件里面都是需要更改后的名字(名字1、等),还有一个文件里是更改前的名字(文件b、等)
我想实现对应到指定文件后重命名,如下
“文件b”改为“名字1”
“文件a”改为“名字4”
“文件d”改为“名字3”
作者:
Shell_HAT
时间:
2013-06-13 22:02
paste -d' ' old.list new.list | while read line; do
mv $line
done
复制代码
作者:
sucbttp
时间:
2013-06-13 23:02
谢谢你, 我试一试 ,如果不明白在跟您请教
回复
2#
Shell_HAT
作者:
sucbttp
时间:
2013-06-13 23:45
真的很不错,谢谢了!!
回复
2#
Shell_HAT
作者:
lbseraph
时间:
2013-06-14 02:24
paste的用法还没玩过
研究下~
作者:
seesea2517
时间:
2013-06-14 10:43
未测试:
paste -d' ' old.list new.list | sed 's/^/mv /e'
复制代码
作者:
sucbttp
时间:
2013-06-15 13:44
回复
2#
Shell_HAT
您好,我还有一个问题要请教您,可不可以根据old.list,查询出文件,然后copy,再根据new.list 把查询出来的文件依依更名呢?
作者:
Shell_HAT
时间:
2013-06-15 22:26
回复
7#
sucbttp
while read line; do
find /tmp/folder1/ -type f -name "$file" -exec cp {} /tmp/folder2/ \;
done < /tmp/folder2/old.list
cd /tmp/folder2/
paste -d' ' old.list new.list | while read line; do
mv $line
done
复制代码
作者:
sucbttp
时间:
2013-06-17 15:38
回复
8#
Shell_HAT
您好,我刚测试没通过,能再麻烦一下么?
提示说
mv: cannot stat `0': No such file or directory
是list 文件写的有问题吗?
作者:
Shell_HAT
时间:
2013-06-17 15:46
回复
9#
sucbttp
我猜是
作者:
sucbttp
时间:
2013-06-17 16:53
回复
10#
Shell_HAT
路径问题,Thank U !! 这个能给积分不?
作者:
Shell_HAT
时间:
2013-06-17 20:02
回复
11#
sucbttp
想给分的话,下次发个悬赏贴就行了。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2