Skip to content

Writing Zip Archives

Igir supports creating .zip archives with the igir zip command.

Note

It is intentional that Igir only supports .zip archives right now.

.zip archives store CRC32 information in their "central directory" which helps drastically speed up Igir's file scanning, and zip archives are easy to create without proprietary tools (e.g. 7-Zip, Rar).

See the reading archives page for more information on archive formats and their capabilities.

TorrentZip

Igir adheres to the TorrentZip standard for zip files. This standard allows ROM managers to write byte-for-byte identical zip files given the same input files.

RVZSTD

The original TorrentZip format uses the widely supported DEFLATE compression algorithm. Gordon J from RomVault has since extended the structured zip format to support Zstandard ("Zstd") compression, which can compress files smaller than DEFLATE with less processing power.

Although the zip format officially added support for Zstd compression in June 2020, support among archive programs and OSes remains quite low. Igir uses the old DEFLATE algorithm by default, but you can instead switch to using Zstandard with the option:

--zip-format rvzstd

Implications for testing

When Igir tests written zip files, it will test to make sure they're valid a TorrentZip or RVSTD file, whichever was specified. This means that zip files that aren't of the expected structured format will be considered invalid, even if they contain all expected files. This isn't a problem for the igir zip command which will rewrite the zip as necessary, but it could be a problem if you have invalid zips in your input paths and omit the command.

The --overwrite-invalid option can help you convert your collection between different zip formats like this:

igir move zip test ^
  --dat "DATs\" ^
  --input "ROMs\" ^
  --output "ROMs\" ^
  --dir-mirror ^
  --zip-format <format> ^
  --overwrite-invalid
igir move zip test \
  --dat "DATs/" \
  --input "ROMs/" \
  --output "ROMs/" \
  --dir-mirror \
  --zip-format <format> \
  --overwrite-invalid
igir move zip test \
  --dat "DATs/" \
  --input "ROMs/" \
  --output "ROMs/" \
  --dir-mirror \
  --zip-format <format> \
  --overwrite-invalid

Tip

You can test if zip files in input directories are valid TorrentZip archives without writing anything with the igir test command.

Example: zipping a ROM collection

One aspect of organizing a ROM collection is to ensure a consistent archive format. You can ensure all ROMs in a collection are in a .zip archive like this:

igir move zip --dat "*.dat" --input "ROMs\" --output "ROMs\"
igir move zip --dat "*.dat" --input "ROMs/" --output "ROMs/"
igir move zip --dat "*.dat" --input "ROMs/" --output "ROMs/"

Excluding files from zipping

There are multiple reasons why you might need some files to be extracted and not in a .zip archive:

  • Most emulators don't support archived BIOS files
  • Some emulators don't support archived disc formats such as .iso or .bin/.cue
  • It may not make sense to compress already compressed formats such as .chd, .cso, and .rvz

You can exclude files from being zipped with the --zip-exclude <glob> option. The "glob" value for this option will be matched against the file's intended output location (as opposed to an input file's location).

You can exclude some disc images like this:

igir copy zip ^
  --dat "*.dat" ^
  --input "ROMs\" ^
  --output "ROMs-Sorted\" ^
  --zip-exclude "**/*.{iso,bin,cue,chd}"
igir copy zip \
  --dat "*.dat" \
  --input "ROMs/" \
  --output "ROMs-Sorted/" \
  --zip-exclude "**/*.{iso,bin,cue,chd}"
igir copy zip \
  --dat "*.dat" \
  --input "ROMs/" \
  --output "ROMs-Sorted/" \
  --zip-exclude "**/*.{iso,bin,cue,chd}"

You can exclude some BIOS files like this:

igir copy zip ^
  --dat "*.dat" ^
  --input "ROMs\" ^
  --output "ROMs-Sorted\" ^
  --zip-exclude "**/*[BIOS]*"
igir copy zip \
  --dat "*.dat" \
  --input "ROMs/" \
  --output "ROMs-Sorted/" \
  --zip-exclude "**/*[BIOS]*"
igir copy zip \
  --dat "*.dat" \
  --input "ROMs/" \
  --output "ROMs-Sorted/" \
  --zip-exclude "**/*[BIOS]*"

Tip

globster.xyz is a great website to test various glob patterns.