g****g 发帖数: 1828 | 1 下载的文件全是乱码:
01_??.mp3 05_???δ?.mp3 09_??????.mp3 13_??÷????.mp3
02_????.mp3 06_????.mp3 10_????.mp3 14_????????.mp3
03_??????.mp3 07_????.mp3 11_????.mp3 15_????????.mp3
04_??·.mp3 08_??????.mp3 12_??????.mp3 16_????é.mp3
我想让他们变成这样子好看些:
01.mp3 03.mp3 05.mp3 07.mp3 09.mp3 11.mp3 13.mp3 15.mp3
02.mp3 04.mp3 06.mp3 08.mp3 10.mp3 12.mp3 14.mp3 16.mp3
运行一下这个script就可以了:
$ more ren.sh
for file in *.mp3
do
newfile=${file/\_*.mp3/.mp3}
mv $file $newfile
done |
j**f 发帖数: 28 | 2 In Debian / Ubuntu
rename s'/_.*.mp3/.mp3/' *.mp3
In Redhat / CentOS
rename _*mp3 .mp3 *.mp3 , never work. Your script is necessary
【在 g****g 的大作中提到】 : 下载的文件全是乱码: : 01_??.mp3 05_???δ?.mp3 09_??????.mp3 13_??÷????.mp3 : 02_????.mp3 06_????.mp3 10_????.mp3 14_????????.mp3 : 03_??????.mp3 07_????.mp3 11_????.mp3 15_????????.mp3 : 04_??·.mp3 08_??????.mp3 12_??????.mp3 16_????é.mp3 : 我想让他们变成这样子好看些: : 01.mp3 03.mp3 05.mp3 07.mp3 09.mp3 11.mp3 13.mp3 15.mp3 : 02.mp3 04.mp3 06.mp3 08.mp3 10.mp3 12.mp3 14.mp3 16.mp3 : 运行一下这个script就可以了: : $ more ren.sh
|
g****g 发帖数: 1828 | 3
thanks. 又学到了东西。rename s的s代表什么?
看ubuntu里的man rename的例子s是在单引号里面的。
rename 's/\.bak$//' *.bak
难道s在里面外面没有关系?
【在 j**f 的大作中提到】 : In Debian / Ubuntu : rename s'/_.*.mp3/.mp3/' *.mp3 : In Redhat / CentOS : rename _*mp3 .mp3 *.mp3 , never work. Your script is necessary
|
s*****o 发帖数: 1262 | |
l*******G 发帖数: 1191 | 5 如果没短线
ls *.mp3 |cat -n|awk '{command="mv "$2" "$1".mp3"; system(command); }' |