日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux能否批量重命名,linux批量重命名方法

發(fā)布時間:2023/12/20 linux 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux能否批量重命名,linux批量重命名方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

經(jīng)常會遇到需要批量重命名文件的情況,用鼠標(biāo)太夸張了,簡單總結(jié)兩種比較簡單的方法:

問題:

存在大量html文件,需要重命名為htm文件

1.rename

通常重命名的命令是mv,Larry Wall寫的rename具有更強(qiáng)大的功能。能夠用perl的正則語法結(jié)構(gòu)進(jìn)行文件重命名。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/' *

上面是rename的man手冊,針對上面重命名html文件的問題,解決如下:

rename 's/.html$/.htm/' *.html

簡單來說就是重命名所有html文件(*.html),將文件名結(jié)尾處.html替換為.htm('s/.html$/.htm/'),其實更簡單的表達(dá)式可以為's/l$//'

2.printf

使用shell命令中的prinf打印出需要的文件名,然后在使用mv重命名

for i in *.html

do

newname="`printf "%s" ${i/html}`"htm

mv $i $newname

done

總結(jié)

以上是生活随笔為你收集整理的linux能否批量重命名,linux批量重命名方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。