💻

MacOSで圧縮ファイルの中に文字化けしているフォルダー・ファイルがあった場合の対策

に公開

文字化けというのは?

例えば、「配置モデル.zip」があり、中には以下のようになっているとする。

配置モデル/bert/tokenizer_config.json
配置モデル/bert/tf_model.h5
配置モデル/classification/config.json

unzip -l 配置モデル.zipを実行すると以下のような表示が出力される。

Length      Date    Time    Name
---------  ---------- -----   ----
      251  04-16-2025 11:50   ��������������/bert/tokenizer_config.json
1491013624  04-16-2025 11:50   ��������������/bert-large-japanese-v2/tf_model.h5
     5349  11-15-2023 11:47   ��������������/classification/config.json

unzipで解凍しようとしたら、下記のエラーが出る

checkdir error:  cannot create /Users/mmedina/Downloads/��������������                 Illegal byte sequence                 unable to process ��������������/bert/tokenizer_config.json 

MacOSなら既存のArchive Utility使ったら?

もちろん、これは一番便利な手法だが、これも失敗する時がある。

ファイル名が問題のでは?

仮にそうだったとしてもファイル名を変えて済む話だが、中のディレクトリーにも日本語の文字があり文字化けしているので、できない。

解決方法

あくまでも一つの手法として紹介する。これ以外にも他のツールはある。

unarをインストールして、それで解凍する

$ brew install unar
...

$ unar 配置モデル.zip
配置モデル.zip: Zip
  配置モデル/bert/  (dir)... OK.
  配置モデル/classification/  (dir)... OK.
Successfully extracted to "./配置モデル".
DXC Lab

Discussion