Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of file name, file and mp3 name and pdf garbled under Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to solve the problem of file name, file and mp3 name and pdf garbled under Linux". In daily operation, it is believed that many people have doubts about how to solve the problem of file name, file and mp3 name and pdf garbled under Linux. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful for you to answer the doubt of "how to solve the problem of file name, file and mp3 name and pdf garbled under Linux"! Next, please follow the editor to study!

If you have just transferred from windows to Linux, you will usually give up because of some Chinese problems. I just installed it and unloaded it several times. In fact, this kind of mentality will never learn anything. Real scholars have a fearless spirit, and they can't find a retreat in their dictionaries. OK, no more bullshit, let's move on to the topic.

Here I use three tools, convmv, iconv, python-mutagen. To deal with the above three issues, the following are described one by one:

Convmv implements the conversion of file names:

Sudo apt-get install convmv

Convmv-f code1-t code2-r

Code1: the character set encoding originally used by the directory. Gb2312, gbk, big5 are supported, gb18030 and big5-hkscs are not supported

Code2: the character set encoding to which it is preconverted. For ubuntu, fill in utf8 here

-r parameter: convert subdirectories

-f: from

-t: to

Dir: directory to be converted

Man convmv view help files, which is very useful. Learning to read Linux help documents is of great benefit to both Linux and English learning. We strongly recommend that you use the man command more often:)

Iconv implements the conversion of file contents:

Iconv-f code1-t code2 oldfile > newfile

Other commands and parameters please use man to check, I am not lazy, I do not want you to become lazy, in any case, we should experience the process ourselves, so that we can really learn it.

Python-mutagen---mp3 ID3 tags setup tool

Mutagen is a Python used to process sound-related data.

Module. It supports ID3 (all versions), APEv2,Ogg Vorbis,FLAC and Ogg

FLAC read, and ID3v1.1,ID3v2.4,APEv2,Ogg Vorbis,FLAC and Ogg

FLAC information is written. It can also be used to read MPEG audio and Xing headers. Flac stream information blocks, as well as Ogg vorbis,Ogg

FLAG stream title. Finally, it contains a module for handling Ogg streams.

Mid3v2-an artist-An album-t title-c comment-g genre mp3file

Set the ID3 tags of mp3file

Find. -iname "* .mp3"-execdir mid3iconv-e GBK {}\

This converts the mp3 file tag code in its subdirectory of the current directory to the correct utf8,-execdir meaning that the following shell script is executed for each file found. In the script,-e GBK means the character set code originally used by the file. Readers can also man find to see the difference between-iname and-name. Hehe, always like to sell you information:)

Solve the PDF garbled problem:

The first step is to install the Chinese language support package

Sudo apt-get install xpdf-chinese-simplified xpdf-chinese-traditional

Open the pdf document after installation, and if you find it is still garbled, proceed to the second step: install poppler-data: starting from 8.04, the source starts to provide support for poppler-data installation packages. You can enter commands directly.

Sudo apt-get install poppler-data

Or go to the official download and install the tar.gz package yourself at

Http://poppler.freedesktop.org/

Compile and install by yourself, I will not elaborate on it here

If after the first and second steps are completed, open the pdf document and change the garbled code into squares, then proceed to the third step to delete the font.

Sudo rm / etc/fonts/conf.d/49-sansserif.conf

Well, here, I believe you can happily use Linux, I am very happy, one time to solve the garbled problem is on the one hand, on the other hand, today my blog is included in Google, hehe, this means that my notes can provide reference for more people, and my notes also draw lessons from many people's notes, which is said to be taken from the people and used by the people:)

You only need to change the Chinese content stored in gbk, gb18030, big5 and other codes in mp3 tags to Unicode codes, and basically all players under Linux can recognize mp3 tags normally.

About the conversion of mp3 code, introduce a tool-Mutagen, if you have installed Quod Libet, then this package has been installed. If not, just execute the following command.

Sudo apt-get install python-mutagen

How to use the tool

# convert the directory where the mp3 file is located, and execute:

Mid3iconv-e gbk * .mp3

# convert all mp3 files (including subdirectories) under the current directory:

Find. -iname "* .mp3"-execdir mid3iconv-e gbk {}

If you find it troublesome to enter commands every time, you can also create a shell script for batch conversion:

Create a new file and write:

The code is as follows:

#! / bin/sh

IFS= ""

Find. -iname "* .mp3"-execdir mid3iconv-e gbk {}

Then save the file, copy it to the directory you want to convert, and execute it (the command to execute the script is # sh filename).

Because the vast majority of mp3 downloaded from the Internet now use gbk/gb18030 coding,-e gbk.

The parameter represents the conversion of gbk-encoded tags to Unicode-encoded tags, but not if the mp3 tags themselves are Unicode-encoded. If you need to convert other encoded files, you can modify them yourself.

Gbk parameters, such as change to gb18030, big5. The converted mp3 tag type is ID3v2 2.4 and the encoding format is UTF-16.

After this step, there will probably be no problem with using all the players under Linux.

Now let's look back and trace back to the root cause, why do these mp3 display normally with Media Player under Windows? Is Linux not as good as Windows? In fact, this reason is very simple, Firefox also can not open a lot of IE can easily open the page, can you explain that Firefox is not as good as IE? People who know about it can understand it at a glance. For the sake of its so-called compatibility, Windows completely ignores specifications and sets its own rules. It seems that its software compatibility is very good, but in fact

In the end, it is the users who destroy it, from a large number of web pages that do not comply with the W3C specification and now a flood of mp3 tags.

And then turn to a better one.

Convert the file name from GBK to UTF8

Sudo apt-get install convmv

Convmv-r-f cpArray36-t utf8? notest? nosmart *

Batch conversion of all file contents in the src directory from GBK to UTF8

Find src-type d-exec mkdir-p utf8/ {}

Find src-type f-exec iconv-f GBK-t UTF-8 {}-o utf8/ {}

Mv utf8/* src

Rm-fr utf8

Convert file contents from GBK to UTF8

Iconv-f gbk-t utf8 $I > newfile

Convert mp3 tag coding

Sudo apt-get install python-mutagen

Find. -iname "* .mp3"-execdir mid3iconv-e GBK {}

MP3 name is garbled under Linux

Solution: install python-mutagen

Installation method (root permissions, you know)

Fedora and other Red Hat:

Yum install python-mutagen

Ubuntu and other debian's:

Apt-get install python-mutagen

After settling down

Mid3iconv-e gbk * .mp3

OK~

At this point, the study on "how to solve the problem of file names, file and mp3 names and pdf garbled under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report