BSD - 以递归方式从目录中的所有文件中删除非ASCII字符

Modified on: Fri, 05 Jul 2019 01:20:02 +0800

我正在尝试将一堆(300GB +)的文件从FAT32驱动器迁移到我的freeNas ZFS文件系统,但我抛出的每个命令(tar,pax,mv,cp)在遇到时都会抛出“无效参数”一个非ASCII文件名 - 它通常是在Windows下创建的东西,它读的是“foo?s bar.mp3 ...”中的内容。可能是撇号等。

任何人都可以帮助使用几行代码递归遍历目录树并重命名文件以删除有问题的字符。

非常感谢。

最佳答案

尝试安装文件系统,并将iocharset选项设置为它使用的编码。

从“装载肥胖选项”部分下的man mount

   iocharset=value
          Character set to use for converting between 8 bit characters and
          16 bit Unicode characters. The default is iso8859-1.  Long file‐
          names are stored on disk in Unicode format.

另请参阅“为vfat安装选项”部分:

   uni_xlate
          Translate  unhandled  Unicode  characters  to  special   escaped
          sequences.   This lets you backup and restore filenames that are
          created with any Unicode characters. Without this option, a  '?'
          is used when no translation is possible. The escape character is
          ':' because it is otherwise illegal on the vfat filesystem.  The
          escape  sequence  that gets used, where u is the unicode charac‐
          ter, is: ':', (u & 0x3f), ((u>>6) & 0x3f), (u>>12).

   utf8   UTF8  is  the  filesystem safe 8-bit encoding of Unicode that is
          used by the console. It can be be  enabled  for  the  filesystem
          with this option or disabled with utf8=0, utf8=no or utf8=false.
          If `uni_xlate' gets set, UTF8 gets disabled.

修改强>

对不起,那是Linux,这是针对BSD的(来自man mount_msdosfs

 -L locale
     Specify locale name used for file name conversions for DOS and
     Win'95 names.  By default ISO 8859-1 assumed as local character
     set.

 -D DOS_codepage
     Specify the MS-DOS code page (aka IBM/OEM code page) name used
     for file name conversions for DOS names.

相关问答

添加新评论