如何更改编码在很多文件? [英] How to change encoding in many files?

查看:101
本文介绍了如何更改编码在很多文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试试这个:

find . -exec iconv -f iso8859-2 -t utf-8 {} \;

但输出到屏幕上,而不是同一个文件。怎么办呢?

but output goes to the screen, not to the same file. How to do it?

推荐答案

试试这个:

find . -type f -print -exec iconv -f iso8859-2 -t utf-8 -o {}.converted {} \; -exec mv {}.converted {} \;

它将使用与'.converted后缀(扩展名)临时文件,然后将其移动到原来的名字,所以一定要小心,如果你有'.converted后缀的文件(我不认为你有)。

It will use temp file with '.converted' suffix (extension) and then will move it to original name, so be careful if you have files with '.converted' suffixes (I don't think you have).

另外这个剧本是不是包含空格的文件名安全的,所以更多的安全,你应该用双引号:{},而不是{}和{} .converted,而不是{} .converted

Also this script is not safe for filenames containing spaces, so for more safety you should double-quote: "{}" instead of {} and "{}.converted" instead of {}.converted

这篇关于如何更改编码在很多文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆