批量修改扩展名
for i in *.mp3; do mv $i `basename $i .mp3`.bak ;done例如将以mp3结尾的文件改名为mp3.bak结尾 rename 's/\.mp3/\.MP3/' *.mp3 楼主的没有问题,已经加入一句话问答
2楼的不生效,请确认 [i=s] 本帖最后由 zhuzhixin 于 2009-4-16 14:18 编辑 [/i]
[code]touch {1..10}.mp3[/code][code]ls[/code][quote]10.mp3 1.mp3 2.mp3 3.mp3 4.mp3 5.mp3 6.mp3 7.mp3 8.mp3 9.mp3[/quote][code]rename '/\.mp3/\.MP3/' *.mp3[/code][code]ls[/code][quote]10.MP3 1.MP3 2.MP3 3.MP3 4.MP3 5.MP3 6.MP3 7.MP3 8.MP3 9.MP3[/quote]\[code]rename 's/\.MP3/\.avi/' *.MP3 && ls[/code][quote]10.avi 1.avi 2.avi 3.avi 4.avi 5.avi 6.avi 7.avi 8.avi 9.avi[/quote] 1. 我的环境是Fedora 10,bash,使用rename命令后,后缀还是没有任何变化
请问zhuzhixin,你的环境是什么?
2. 我看了一下rename的man,将你的语句修改如下:
rename .mp3 .MP3 *.mp3
这样就可以了 [i=s] 本帖最后由 zhuzhixin 于 2009-4-16 17:36 编辑 [/i]
[quote]1. 我的环境是Fedora 10,bash,使用rename命令后,后缀还是没有任何变化
请问zhuzhixin,你的环境是什么?[/quote]
Linux debian 2.6.26-2-amd64
Debian GNU/Linux squeeze/sid \n \l
dash
[quote]2. 我看了一下rename的man,将你的语句修改如下:
rename .mp3 .MP3 *.mp3
这样就可以了
[/quote][code]man rename[/code][quote]
NAME
rename - renames multiple files
SYNOPSIS
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
DESCRIPTION
"rename" renames the filenames supplied according to the rule specified as the first argument. The perlexpr
argument is a Perl expression which is expected to modify the $_ string in Perl for at least some of the filenames
specified. If a given filename is not modified by the expression, it will not be renamed. If no filenames are
given on the command line, filenames will be read via standard input.
For example, to rename all files matching "*.bak" to strip the extension, you might say
rename 's/\.bak$//' *.bak
To translate uppercase names to lower, you’d use
rename 'y/A-Z/a-z/' *
[/quote] 感谢zhuzhixin,已经添加到一句话问答
页:
[1]