linux之中对文件名和文件进行编码转换

shell的内容如下

#!/bin/bash
myfunc()
{
        for x in $(ls)
        do
                if [ -f "$x" ];then
convmv -f UTF-8 -t gb2312 --notest "$x"
                elif [ -L "$x" ];then
                        convmv -f UTF-8 -t gb2312 --notest "$x"
                else

convmv -f UTF-8 -t gb2312 --notest "$x"
                        cd "$x";
                        myfunc;
                        cd ..
                fi
        done
}

myfunc


新建这个shell之后,将内容拷贝过去,然后到要转化编码的目录执行命令:   sh -x  bashname

即可,可能会出现死循环的情况注意查看


转化命令表示的意思为将UFT-8编码的文件修改为编码为gb2312编码的文件


可以将一个目录中所有的子目录子文件都进行编码转换


for linux and python
原文地址:https://www.cnblogs.com/kellyseeme/p/5525204.html