日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
使用Linux批量重命名文件(批量重命名linux)

Nowadays, linux is widely used in our daily life and work. Releasing users from managing files through tedious mouse clicks, Linux has provided great convenience for us to manage files. Especially in the case of renaming multiple files, using Linux commands to conduct batch operation for our applications is a really effective way.

Take the case of using Linux to rename pictures as an example. Suppose we have a folder containing multiple pictures whose names are in a chaotic pattern. We can use the following command to easily rename them “image_1.jpg”, “Image_2.jpg” and so on.

`cd`

`for i in {1..50} ; do mv Image.jpg Image_${i}.jpg; done`

Basically, what this command does is looping through “1 to 50” and use “mv” attribute to execute the renaming process while substituting the suffix “Image_${i}.jpg”.

But if we want to go further and customize the naming pattern, and also avoid name conflicts (e.g., Image_2.jpg already exists), we may need more complex commands:

`ls|grep “Image”|cut -d “.” -f 1|xargs -I file num=`ls|grep “Image”|grep -c “^file”`; mv file.jpg Image_${num}.jpg`

The command is composed of different segments.

`ls` is used to check all the files in the current folder, `grep “Image”` is to limit the names of files to “Image” and `cut -d “.” -f 1` is to get rid of suffix.

`xargs` converts the output of “l(fā)s|grep “Image”” as the input parameter of “num=`ls|grep “Image”|grep -c “^file”`”, which is used to generate a number after “Image_”.

At last, `mv file.jpg Image_${num}.jpg` is to complete the renaming process.

By carrying out the commands above, we can easily customize the naming patterns for our files and make them in order without conflicts. Hope this article has offered you a good insight into the way of using Linux to rename multiple files.

香港服務器選創(chuàng)新互聯(lián),2H2G首月10元開通。
創(chuàng)新互聯(lián)(www.cdcxhl.com)互聯(lián)網服務提供商,擁有超過10年的服務器租用、服務器托管、云服務器、虛擬主機、網站系統(tǒng)開發(fā)經驗。專業(yè)提供云主機、虛擬主機、域名注冊、VPS主機、云服務器、香港云服務器、免備案服務器等。


網頁名稱:使用Linux批量重命名文件(批量重命名linux)
網站URL:http://m.5511xx.com/article/ccsgpee.html