Skip to content

Output Directory Cleaning

The igir clean command can be used when writing (igir copy, igir move, and igir link) to delete files from the --output <path> directory that were not considered for writing.

Note

The term "considered" is used here because output files that already exist won't be overwritten by default. These output file paths were considered for writing, but then Igir chose not to write them.

Only files from --input <path> directories can be used when writing to the --output <path> directory. Therefore, the output files that will be cleaned (because they weren't considered for writing) are files that:

Warning

Because only input files will be considered for writing to the output directory, you will want your input files to be a superset of your output files. In other words, if a file isn't in your input files, it will be cleaned from your output directory.

It is a best practice to include your output directory as an input directory when cleaning files. This will ensure any previously written valid files won't be cleaned.

The golden rule

The golden rule of the igir clean command is it will not delete files in any directory tree that it did not write to.

In practical terms, this means:

1. If no file was written (i.e. no input file matched any ROM in any DAT), then igir clean will not delete any files.

2. If tokens are used with the --output <path> option, only subdirectories that are written to will be considered for cleaning.

For example, if the output directory is specified as --output "games/{mister}", and only Game Boy Color games are found in --input <path>, then only the games/Gameboy/ directory would be considered for cleaning. Other directories that may already exist such as games/GBA/ and games/NES/ would not be considered for cleaning, as Igir did not write there.

In other words, games/{mister} is not equivalent to games/*. Igir will not indiscriminately delete files in games/.

If you want to clean every directory in games/, you could specify it as both the --input <path> and --output <path>:

igir move clean --dat "*.dat" --input "games\" --output "games\{mister}\"
igir move clean --dat "*.dat" --input "games/" --output "games/{mister}/"
igir move clean --dat "*.dat" --input "games/" --output "games/{mister}/"

Exclusions

The --clean-exclude <path> option exists so that one or more paths (with support for globbing) can be excluded from deletion.

See the Analogue Pocket page for a practical example.

Backing up cleaned files

By default, Igir will recycle cleaned files, and if recycle fails, then it will delete them. This is potentially destructive, so a --clean-backup <path> option is provided to instead move files to a backup directory.

The input directory structure is not maintained, no subdirectories will be created in the backup directory. Files of conflicting names will have a number appended to their name, e.g. File (1).rom.

Dry run

The --clean-dry-run option exists to see what paths igir clean would delete, without actually deleting them.

Note

You will want to set the log level to at least DEBUG (-vv) in order to see actions that were skipped, such as cleaning.

Usage:

igir [commands..] clean [options] --clean-dry-run -vv
igir [commands..] clean [options] --clean-dry-run -vv
igir [commands..] clean [options] --clean-dry-run -vv