# How to Specify Output Path for Downloaded .ipa Files in IPATool

> Specify the output path for downloaded ipa files in IPATool using the --output flag. Easily direct where your packages are saved.

- Repository: [Majd/ipatool](https://github.com/majd/ipatool)
- Tags: how-to-guide
- Published: 2026-09-01

---

**Use the `--output` (or `-o`) flag with the `download` command to designate either a target directory or an explicit file path for the saved package.**

When working with the `majd/ipatool` repository to download iOS applications from the App Store, controlling the destination of .ipa files is critical for automated workflows and file organization. The tool provides a built-in mechanism to specify output paths via command-line arguments, with logic implemented in the core download subsystem and exposed through the CLI interface.

## The `--output` Flag and Default Behavior

The `download` command accepts the `--output` flag (short form `-o`) to define the destination for the retrieved .ipa package. According to the flag declaration in [`cmd/download.go`](https://github.com/majd/ipatool/blob/main/cmd/download.go) (lines 52-55), this parameter accepts a string path that determines where the file is written.

If you omit the `--output` flag, IPATool writes the file to your current working directory and constructs the filename automatically. As implemented in [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go) (lines 24-33), the default naming convention combines the application's bundle identifier, numeric App Store ID, and version number into a single string (e.g., `com.example.app_123456_1.0.ipa`).

## Path Resolution Logic

IPATool differentiates between directory and file paths through the `resolveDestinationPath` function located in [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go) (lines 5-27). This function employs an `isDirectory` check to determine the path type and behaves as follows:

- **Directory path**: When the supplied path resolves to an existing directory, IPATool appends the auto-generated filename to that directory path.
- **Explicit file path**: When the path includes a specific filename (e.g., `CustomName.ipa`), IPATool writes the package directly to that location, ignoring the automatic naming scheme.

The final path resolution occurs in [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go) (lines 90-98), where the destination is finalized before the download begins.

## Practical Examples

The following examples demonstrate how to specify output paths in different scenarios:

Download to a specific directory using auto-generated filenames:

```bash
ipatool download --app-id 123456 --output ./my-downloads

```

This results in a file such as `./my-downloads/com.example.myapp_123456_1.2.ipa`.

Specify a custom filename explicitly:

```bash
ipatool download -i 123456 -o ./my-downloads/CustomName.ipa

```

This writes the package directly to `./my-downloads/CustomName.ipa`.

Use a bundle identifier with a target directory:

```bash
ipatool download -b com.example.myapp -o /tmp

```

This saves the file to `/tmp/com.example.myapp_123456_1.2.ipa`.

## Summary

- The `--output` or `-o` flag controls the destination for downloaded .ipa files in IPATool.
- Omitting the flag defaults to the current directory with auto-generated filenames based on bundle ID, app ID, and version.
- Providing a directory path results in the auto-generated file being placed inside that directory.
- Providing a full file path bypasses automatic naming and writes directly to the specified location.
- The resolution logic resides in the `resolveDestinationPath` function within [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go).

## Frequently Asked Questions

### What happens if I do not specify the `--output` flag?

If the `--output` flag is omitted, IPATool defaults to the current working directory for the download location. The filename is automatically generated from the application's metadata, specifically the bundle identifier, numeric ID, and version, as defined in [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go) (lines 24-33).

### Can I set a custom filename instead of using the auto-generated one?

Yes. When you provide a complete file path (such as `~/Apps/MyApp.ipa`) to the `--output` flag, IPATool treats this as an explicit file destination. The `resolveDestinationPath` function detects this as a non-directory path and returns it unchanged, causing the tool to write directly to that filename while ignoring the default naming convention.

### What is the format of the auto-generated filename?

The auto-generated filename follows the pattern `bundleIdentifier_appID_version.ipa`, constructed in [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go) (lines 24-33). For example, an app with bundle ID `com.example.app`, numeric ID `123456`, and version `1.0` results in `com.example.app_123456_1.0.ipa`.

### Where is the output path handling implemented in the source code?

The destination logic is implemented in the `resolveDestinationPath` function within [`pkg/appstore/appstore_download.go`](https://github.com/majd/ipatool/blob/main/pkg/appstore/appstore_download.go) (lines 5-27). This function checks whether the provided path is a directory and determines the final write location. The CLI flag itself is declared and bound in [`cmd/download.go`](https://github.com/majd/ipatool/blob/main/cmd/download.go) (lines 52-55).