Linux solves the garbled problem of file name, file, mp3 name, and pdf.

Source: Internet
Author: User
If I just switched from windows to Linux, I usually give up because of some Chinese problems. I just installed it and uninstalled it several times, in fact, this kind of mentality will never be able to learn anything. Real scholars have a fearless spirit and cannot find them in their dictionary, next we will go to the subject.

If I just switched from windows to Linux, I usually give up because of some Chinese problems. I just installed it and uninstalled it several times, in fact, this kind of mentality will never be able to learn anything. Real scholars have a fearless spirit and cannot find them in their dictionary, next we will go to the subject.

Here I have used three tools, convmv, iconv, and python-mutagen. To solve the above three problems, we will introduce them one by one:

Convmv converts file names:
Sudo apt-get install convmv
Convmv-f code1-t code2-r

Code1: character set encoding used by the Directory. Supports gb2312, gbk, big5, does not support gb18030 and big5-hkscs
Code2: Pre-converted character set encoding. For ubuntu, enter utf8 here

-R parameter: conversion subdirectory
-F: from
-T:
Dir: directory to be converted

Man convmv is very useful for viewing help files. Learning to read Linux help documents has great benefits for both Linux and English learning. We strongly recommend that you use man more.Command:)

Iconv implements file content conversion:

Iconv-f code1-t code2 oldfile> newfile

For other commands and parameters, please use man for reference. I am not lazy. I don't want to make everyone lazy. In any case, we should try this process on our own, in this way, we can truly learn it.

Python-mutagen --- mp3 ID3 tags setting tool
Mutagen is a Python program used to process sound-related data.
Module. It supports ID3 (all versions), APEv2, Ogg Vorbis, FLAC, and Ogg
FLAC reading, and ID3v1.1, ID3v2.4, APEv2, Ogg Vorbis, FLAC, and Ogg
FLAC information writing. It can also be used to read MPEG audio and Xing title. FLAC stream information blocks, as well as Ogg vorbis, Ogg
FLAG stream title. At last, it contains a module for processing the Ogg stream.
Mid3v2-a artist-A album-t title-c comment-g genre mp3file
Set ID3 tags of mp3file
Find.-iname "*. mp3"-execdir mid3iconv-e GBK {};

This will convert the mp3 file tag in the subdirectory of the current directory to utf8 correctly.-execdir means to execute the shell script after each file found, in the script,-e GBK indicates the character set encoding used by the file. You can also find the difference between-iname and-name. Haha, I always like to sell it to you :)
PDF garbled problem solution:
Step 1: Install the Chinese language support package:
Sudo apt-get install xpdf-chinese-simplified xpdf-chinese-traditional
After installation, open the pdf file. If the file is still garbled, perform step 2, install and install poppler-data: Starting from 8.04, and provide support for the poppler-data installation package in the source, you can directly enter the command
Sudo apt-get install poppler-data
Download the tar.gz package and install it on your own.
Http://poppler.freedesktop.org/
, Compile and install it by yourself.
If the first and second steps are complete, and the Chinese garbled characters in the pdf file are converted into squares, the third step is to delete the font.
Sudo rm/etc/fonts/conf. d/49-sansserif.conf
Now, I believe everyone can use Linux happily. I am very happy to solve the problem of garbled code at one time. On the other hand, my blog is indexed by Google today, oh, this means that my notes can be used for reference by more people. In the same way, my notes also draw on the notes of many people. The so-called "from the people, to the people :)

You only need to change the Chinese content stored in the mp3 tags using gbk, gb18030, and big5 encoding to Unicode encoding. Basically, all Linux players can recognize the mp3 tags normally.
For mp3 encoding conversion, we will introduce a tool named Mutagen. If you have installed Quod Libet, this package has been installed. If not, run the following command.

Sudo apt-get install python-mutagen

How to use the tool

# Convert the mp3 file directory and run the following command:
Mid3iconv-e gbk *. mp3
# Convert all mp3 files (including subdirectories) in the current directory and execute:
Find.-iname "*. mp3"-execdir mid3iconv-e gbk {};
If you think it is troublesome to enter a command every time, you can also create a shell script to perform batch conversion:
New file, write:

#!/bin/shIFS=""find . -iname "*.mp3" -execdir mid3iconv -e gbk {}; 

 

The Code is as follows:
#! /Bin/sh
IFS = ""
Find.-iname "*. mp3"-execdir mid3iconv-e gbk {};

Save the file, copy it to the directory you want to convert, and run it (the command for executing the script is # sh filename ).

Because the vast majority of mp3 files downloaded on the Internet now use gbk/gb18030 encoding,-e gbk
The parameter indicates converting the gbk encoded tags to Unicode encoding. If the mp3 tags are Unicode encoded, they are not converted. If you want to convert other encoding files, you can modify them by yourself.
Change the gbk parameter to gb18030 or big5. The converted mp3 tag type is ID3v2 2.4 and the encoding format is UTF-16.

After this step, it is estimated that there is no problem to use all players in Linux.
Next, let's look back at the root cause. Why are these mp3 files normally displayed with Media Player in Windows? Is Linux not as good as Windows? In fact, this principle is very simple. Firefox cannot open many pages that can be easily opened by IE. Does it show that Firefox is not as good as IE? People with knowledge can understand it at a glance. For its so-called compatibility, Windows completely ignores specifications and custom rules. It seems that its software compatibility is good. In fact
In the end, users are destroyed, from a large number of webpages that do not comply with W3C specifications and the overwhelming mp3 tags.
Turn to another cool
Convert the file name from GBK to UTF8
Sudo apt-get install convmv
Convmv-r-f cpArray36-t utf8? Notest? Nosmart *
Batch convert all files 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 the file content from GBK to UTF8
Iconv-f gbk-t utf8 $ I> newfile
Convert mp3 tag Encoding
Sudo apt-get install python-mutagen
Find.-iname "*. mp3"-execdir mid3iconv-e GBK {};

MP3 name garbled characters in Linux

Solution: Install python-mutagen
Installation Method (root permission, you know)
Red Hat such as fedora:
Yum install python-mutagen
For debian such as ubuntu:
Apt-get install python-mutagen
After security
Mid3iconv-e gbk *. mp3
OK ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.