Procedures for downloading items, filtering by format/pattern, bulk downloading from collections, and mirroring entire collections via the `ia` CLI on pi-nas.
---
## Prerequisites
-`ia` CLI installed on pi-nas (192.168.1.245) — v5.7.2
- Authenticated if downloading restricted items: `ia configure`
- Sufficient storage on pi-nas (check with `df -h`)
- Reference: `ia-cli-reference.md` for search/query syntax
---
## 1. Download a Single Item
An "item" is a logical unit on archive.org identified by its identifier (visible in the URL: `archive.org/details/<identifier>`).
```bash
# Download all files in an item to ./<identifier>/
ia download <identifier>
# Example
ia download prelinger_films
```
The default creates a directory named after the identifier containing all files (originals + derivatives).
### Gate
Verify the download directory exists and has files:
```bash
ls -la <identifier>/
```
---
## 2. Filtered Downloads
### By glob pattern
Download only files matching a shell glob pattern.
```bash
# Only PDFs
ia download <identifier> --glob="*.pdf"
# Only MP4 video files
ia download <identifier> --glob="*.mp4"
# Multiple patterns (pipe-separated)
ia download <identifier> --glob="*.pdf|*.epub"
```
### With exclusions
Exclude patterns require `--glob` to also be set.
```bash
# All MP4s except low-quality variants
ia download <identifier> --glob="*.mp4" --exclude="*512kb*"
# All files except metadata/review XMLs
ia download <identifier> --glob="*" --exclude="*_meta.xml|*_reviews.xml|*_files.xml"
# Multiple exclusions
ia download <identifier> --glob="*.mp4" --exclude="*512kb*|*_thumb*"
```
### By format name
Download files of a specific archive.org format (as shown by `ia metadata --formats`).
```bash
# Check available formats first
ia metadata <identifier> --formats
# Download only a specific format
ia download <identifier> --format="512Kb MPEG4"
ia download <identifier> --format="PDF"
ia download <identifier> --format="EPUB"
```
**Note:** `--format` is incompatible with `--glob` and `--exclude`. Use one approach or the other.
### On-the-fly formats
Some formats (EPUB, MOBI, DAISY, MARCXML) are generated on demand.
```bash
ia download <identifier> --on-the-fly --format="EPUB"
```
---
## 3. Download Options
### Control output location
```bash
# Download to a specific directory
ia download <identifier> --destdir=/mnt/archive/downloads/
# Flatten directory structure (no subdirectory per item)
ia download <identifier> --no-directories
```
### Resume interrupted downloads
```bash
# Resume — skips files that already exist and match checksum
ia download <identifier> --checksum
# Checksum mode compares MD5 hashes — safe to re-run
```
### Preserve timestamps
```bash
# Keep original timestamps from archive.org
ia download <identifier> --no-change-timestamp
```
### Dry run
```bash
# See what would be downloaded without actually downloading
ia download <identifier> --dry-run
```
---
## 4. Bulk Download from Search Results
Pipe search results directly into download. This is the primary method for downloading multiple items.
### Basic pattern
```bash
# Search → itemlist → download
ia search 'collection:prelinger mediatype:movies' --itemlist | \
ia download --itemlist -
# The - tells ia download to read identifiers from stdin
```
### With filters
```bash
# Download only PDFs from all items in a collection
ia search 'collection:arrl_qst' --itemlist | \
ia download --itemlist - --glob="*.pdf"
# Download only MP3s from an audio collection
ia search 'collection:librivoxaudio' --itemlist | \
ia download --itemlist - --glob="*.mp3"
```
### With destination directory
```bash
# Download to a specific location
ia search 'collection:prelinger' --itemlist | \
ia download --itemlist - --destdir=/mnt/archive/prelinger/
```
### Save itemlist for reuse
When a search is large, save the itemlist first so you can resume without re-searching.
```bash
# Step 1: Save itemlist
ia search 'collection:prelinger mediatype:movies' --itemlist > prelinger-items.txt
# Step 2: Check count
wc -l prelinger-items.txt
# Step 3: Download from file
ia download --itemlist prelinger-items.txt --glob="*.mp4"
# Step 4: Resume if interrupted (just re-run with --checksum)
ia download --itemlist prelinger-items.txt --glob="*.mp4" --checksum
```
---
## 5. Bulk Download with GNU Parallel
For faster bulk downloads, use GNU Parallel for concurrent item downloads.