トップ 一覧 検索 ヘルプ RSS ログイン

tips-unzipの変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!!! Windows で作成したzip ファイルを解凍すると日本語ファイルが文字化け
!! unzip でなく
unar を使う
 > unar --help 
 unar v1.10.7 (Apr  8 2020), a tool for extracting the contents of archive files.
 Usage: unar [options] archive [files ...]
 
 Available options:
 -output-directory (-o) <string>    The directory to write the contents of the archive to.
                                   Defaults to the current directory. If set to a single
                                   dash (-), no files will be created, and all data will
                                   be output to stdout.
 -force-overwrite (-f)              Always overwrite files when a file to be unpacked
                                   already exists on disk. By default, the program asks
                                   the user if possible, otherwise skips the file.
 -force-rename (-r)                 Always rename files when a file to be unpacked already
                                   exists on disk.
 -force-skip (-s)                   Always skip files when a file to be unpacked already
                                   exists on disk.
 -force-directory (-d)              Always create a containing directory for the contents
                                   of the unpacked archive. By default, a directory is
                                   created if there is more than one top-level file or
                                   folder.
 -no-directory (-D)                 Never create a containing directory for the contents of
                                   the unpacked archive.
 -password (-p) <string>            The password to use for decrypting protected archives.
 -encoding (-e) <encoding name>     The encoding to use for filenames in the archive, when
                                   it is not known. If not specified, the program attempts
                                   to auto-detect the encoding used. Use "help" or "list"
                                   as the argument to give a listing of all supported
                                   encodings.
 -password-encoding (-E) <name>     The encoding to use for the password for the archive,
                                   when it is not known. If not specified, then either the
                                   encoding given by the -encoding option or the
                                   auto-detected encoding is used.
 -indexes (-i)                      Instead of specifying the files to unpack as filenames
                                   or wildcard patterns, specify them as indexes, as
                                   output by lsar.
 -no-recursion (-nr)                Do not attempt to extract archives contained in other
                                   archives. For instance, when unpacking a .tar.gz file,
                                   only unpack the .gz file and not its contents.
 -copy-time (-t)                    Copy the file modification time from the archive file
                                   to the containing directory, if one is created.
 -forks (-k) <visible|hidden|skip>  How to handle Mac OS resource forks. "visible" creates
                                   AppleDouble files with the extension ".rsrc", "hidden"
                                   creates AppleDouble files with the prefix  "._", and
                                   "skip" discards all resource forks. Defaults  to
                                    "visible".
 -quiet (-q)                        Run in quiet mode.
 -version (-v)                      Print version and exit.
 -help (-h)                         Display this information.

!! unzip 6.0 
SRC
 http://www.info-zip.org/
 http://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/
Patch
 https://bugs.archlinux.org/task/15256
Work
 patch -u -p1  < unzip60-alt-iconv-utf8.patch

! 日本語パッチ
 # wget 'http://sourceforge.jp/frs/g_redir.php?m=jaist&f=%2Finfozip%2FUnZip+6.x+%28latest%29%2FUnZip+6.0%2Funzip60.tar.gz' -O unzip60.tar.gz
 # wget https://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz/download

 # wget https://sourceforge.net/projects/infozip/files/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz/download -O unzip60.tar.gz
 # tar zxvf unzip60.tar.gz
 # cd unzip60
 # wget http://gist.github.com/raw/573753/unzip-6.0-japanese_charset.patch
 # patch -p1 < unzip-6.0-japanese_charset.patch
 # make -f unix/Makefile LOCAL_UNZIP="-D_FILE_OFFSET_BITS=64 -DNO_LCHMOD -D_MBCS -DNO_WORKING_ISPRINT" generic_gcc
 # make -f unix/Makefile LOCAL_UNZIP="-D_FILE_OFFSET_BITS=64 -DNO_LCHMOD -D_MBCS -DNO_WORKING_ISPRINT" install
 # which unzip

== # wget 'http://sourceforge.jp/frs/g_redir.php?m=jaist&f=%2Finfozip%2FUnZip+6.x+%28latest%29%2FUnZip+6.0%2Funzip60.tar.gz' -O unzip60.tar.gz ==


!! unzip-5.5 は以下
SRC

http://www.info-zip.org/

日本語パッチ
http://ebuild.gentoo.gr.jp/view.php?cat=app-arch&app=unzip&visible=

日本語のパスワードがかかったzipを展開
普通に ASCII キャラクタのパスワードがかけられた ZIP を展開するなら

 unzip file.zip
 ... password: [ここでパスワードを入れる]

を実行して普通にパスワードを入れればいい。でも、日本語(Shift-JIS)のパスワードがかかった ZIPファイルを展開するにはどうしたらいいだろうか。このためには、まず、端末で日本語を入力できるようにしておかなければならない。kinput2 や ATOK などお好みのものを使えばよい。そうした上で

 unzip -P`nkf -s` file.zip
 [ここでパスワードを入力]
 Ctrl-d (コントロールキーを押したまま d を押す)

とすると、パスワードが正しければ展開されるはずだ。

上で端末で入力する方法を書いたけどエディタでパスワードを書いたファイルをつくって、それを Shift-JIS で保存しておいても同じようにできる。そのファイルをpasswd.txtとしよう。

unzip -P`cat passwd.txt` file.zip

で大丈夫のはず。