INDEX
コマンドラインでキャビネットファイルの作成・展開
ちなみに、キャビネットファイルは、仕様上 2G を越えるサイズのファイルを扱えない。
キャビネットファイルの作成
コマンドラインオプション
C:\>makecab /?
Microsoft (R) Cabinet Maker - Version 5.1.2600.5512
Copyright (c) Microsoft Corporation. All rights reserved..
MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
MAKECAB [/V[n]] [/D var=value ...] /F directive_file [...]
source File to compress.
destination File name to give compressed file. If omitted, the
last character of the source file name is replaced
with an underscore (_) and used as the destination.
/F directives A file with MakeCAB directives (may be repeated).
/D var=value Defines variable with specified value.
/L dir Location to place destination (default is current directory).
/V[n] Verbosity level (1..3).
単一ファイルの圧縮
圧縮したいファイルを指定すればキャビネットファイルが作成される。このとき作成されるファイル名は元のファイル名の最後の文字をアンダースコア(_)に変えた物になる。拡張子を .cab にしたい場合は、出力ファイル名を指定する。
C:\>makecab sample.txt Microsoft (R) Cabinet Maker - Version 5.1.2600.5512 Copyright (c) Microsoft Corporation. All rights reserved.. 100.00% [flushing current folder]
C:\>makecab sample.txt sample.cab Microsoft (R) Cabinet Maker - Version 5.1.2600.5512 Copyright (c) Microsoft Corporation. All rights reserved.. 100.00% [flushing current folder]
makecab コマンドのバグ
Windows XP および Server 2003 に付属する makecab は、キャビネットファイルに残るタイムスタンプが、ファイルの作成日時になっている(2000とVista以降は更新日時)。
- OS によって 挙動の違う makecab.exe が同梱されている - Windows 2000 Blog
キャビネットファイルの展開
コマンドラインオプション
C:\>expand /?
Microsoft (R) File Expansion Utility Version 5.1.2600.0
Copyright (C) Microsoft Corp 1990-1999. All rights reserved.
圧縮されたファイルを展開します。
EXPAND [-r] 展開元 展開先
EXPAND -r 展開元 [展開先]
EXPAND -D CABファイル名 [-F:ファイル名]
EXPAND CABファイル名 -F:ファイル名 展開先
-r 展開されたファイルの名前を変更します。
-D 展開元ファイルにあるファイルを一覧表示します。
展開元 展開元のファイルを指定します。ワイルドカードも使用できます。
-F:ファイル名 CAB ファイルから展開するファイルの名前を指定します。
展開先 展開先のファイルまたはパスを指定します。
展開先にはディレクトリも指定できます。
展開元ファイルが複数で、-r オプションが指定されていない
場合は、展開先はディレクトリである必要があります。
キャビネットファイル内の一覧表示
-D オプションを指定し一覧を表示するキャビネットファイルを指定する。ただし、圧縮されたファイルが階層構造になっていてもフラットになって表示される。
C:\>expand -D sample.tx_ Microsoft (R) File Expansion Utility Version 5.1.2600.0 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. sample.tx_: sample.txt
C:\>expand -D samples.cab Microsoft (R) File Expansion Utility Version 5.1.2600.0 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. samples.cab: sample.1st samples.cab: sample.txt 合計 2 ファイル
単一ファイルの展開
圧縮時のオリジナルファイル名で展開する場合は、-rオプションを指定する。未指定の場合はキャビネットファイルと同じ名前になる(その為、展開先のディレクトリの指定が必要)。
C:\>expand -r sample.tx_ Microsoft (R) File Expansion Utility Version 5.1.2600.0 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. sample.tx_ を sample.txt に展開しています。
または、単純に圧縮されたファイルと展開時のファイル名(絶対パスも可)を指定する。
C:\>expand sample.tx_ sample1.txt Microsoft (R) File Expansion Utility Version 5.1.2600.0 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. sample.tx_ を sample1.txt に展開しています。
複数ファイルの展開
複数ファイル存在するファイルを展開する場合は、-Fオプションで展開するファイル(すべての場合は -F:*)を指定し、展開先のディレクトリ(事前に作成しておく)を指定する。ただし、キャビネットファイル内で階層構造になっていても無視されて展開される。
C:\>mkdir temp C:\>expand samples.cab -F:* temp Microsoft (R) File Expansion Utility Version 5.1.2600.0 Copyright (C) Microsoft Corp 1990-1999. All rights reserved. samples.cab を temp\sample.1st に展開しています。 samples.cab を temp\sample.txt に展開しています。 合計 2 ファイル
自動展開キャビネットファイル
2000 / XP に付属の IExpress を使って作成出来る。詳細は Win32/IExpress 参照。
最終更新時間:2013年01月09日 15時29分09秒 指摘や意見などあればSandBoxのBBSへ。