iaAugust 22, 2026
The Internet Archive’s command-line tool, ia, makes it easy to upload a folder of files as its own item — complete with title, description, and a cover image. Here’s the whole process, step by step.
pip install internetarchive
ia configure
Enter your archive.org email and password when prompted. This only needs to be done once.
Before uploading, it’s worth confirming your PDFs (or other files) aren’t corrupted. qpdf is a solid free validator:
brew install qpdf
cd /path/to/your/folder
for f in *.pdf; do
qpdf --check "$f" || echo "Check this one: $f"
done
Minor “warnings” are usually harmless — only real “errors” need attention.
Archive.org will use an image as the item’s thumbnail if you name it with an _itemimage suffix, for example:
0_MyFolder_itemimage.jpg
The 0_ prefix makes sure it sorts first. A square image around 500–1000px works well. Drop it right into the folder alongside your other files.
ia upload \
--retries=120 \
--sleep=120 \
--checksum \
"My_Unique_Identifier" \
/path/to/your/folder/* \
--metadata="title:My Collection Title" \
--metadata="description:A short description of what this collection contains." \
--metadata="language:eng" \
--metadata="mediatype:texts"
A few notes on this command:
"My_Unique_Identifier") becomes the item’s permanent URL — archive.org/details/My_Unique_Identifier — so choose it carefully; it can’t be changed later.mediatype should be texts for documents, or software for games and applications.--checksum skips re-uploading files that are already present (useful for retries).--retries and --sleep make the upload resilient to network hiccups.If you have several folders that should each become their own item, loop over them:
#!/bin/bash
BASE_DIR="/path/to/parent/folder"
FOLDERS=("Folder_A" "Folder_B" "Folder_C")
for folder in "${FOLDERS[@]}"; do
ia upload \
--retries=120 \
--sleep=120 \
--checksum \
"$folder" \
"$BASE_DIR/$folder"/* \
--metadata="title:$folder" \
--metadata="language:eng" \
--metadata="mediatype:texts"
done
Save this as a .sh file and run it with:
bash upload_all.sh
It will work through each folder one at a time, uploading it as its own archive.org item.
Once uploads finish, visit archive.org/details/YOUR_IDENTIFIER to confirm the title, description, and files all look right — and that your cover image shows up as the thumbnail.
If you’re uploading many folders in a loop, it’s important to know: a single bad file doesn’t just fail on its own and get skipped — it cuts that folder’s upload short. When ia upload hits a corrupted PDF (or any file the server rejects), it logs an error and then abandons the rest of the files in that folder entirely, skipping straight to the next folder in the script’s loop. Any files that would have come after the bad one alphabetically simply never get uploaded on that pass.
This means one corrupted file can silently leave a chunk of a folder’s contents missing from archive.org, with nothing in the log to flag it beyond the single error line. A couple of practical takeaways:
error uploading to catch which folder got cut short.--checksum is included, already-uploaded files get skipped automatically, and everything that was cut off the first time (including files that came after the failure point) will now go up.qpdf --check before re-uploading.If you re-run the batch script — say, to push up a repaired file — you may notice that a handful of files which already uploaded successfully get uploaded again too, even though --checksum is supposed to skip anything already present. This isn’t a bug, and it’s worth understanding rather than being alarmed by it.
What’s happening: ia upload’s --checksum flag doesn’t compare against your local upload history — it asks archive.org’s servers, live, “what files currently exist on this item, and what are their checksums?” and compares your local files against that answer.
The catch is that archive.org doesn’t instantly finish processing a file the moment the upload completes. In the background, it runs what’s called a derive process — this is where the server re-registers the item, regenerates its file listing, builds any auxiliary formats/metadata, and generally “settles” the item into its final state. This normally happens quickly, but if a folder’s upload was interrupted (say, by a corrupted file causing an early exit), the item can be left in a less-settled state for a bit longer.
If you re-run the script again soon after, ia upload may query the item’s metadata before derive has fully caught up, get an incomplete picture, and conclude that certain files aren’t confirmed present yet — so it uploads them again, just to be safe.
The good news: this is completely harmless. Since a re-uploaded file has the same filename, it simply overwrites the existing copy on the item rather than creating a duplicate. And because the script already includes -H "x-archive-keep-old-version:0", archive.org doesn’t even keep the previous version around — so there’s never any clutter or duplicate entries, no matter how many times a given file gets pushed up.
If you want to double-check what’s really on an item — rather than relying on the terminal log — ia has commands for this, similar to ls.
List just the filenames on an item:
ia list Macintosh_Garden_Manuals_2024_C
Get full detail (size, checksum, format, etc.) for every file:
ia metadata Macintosh_Garden_Manuals_2024_C
This returns the item’s full metadata as JSON, including a files array — this is the same data source ia upload --checksum itself checks against.
A quick way to spot differences between your local folder and the live item:
# What's on archive.org
ia list Macintosh_Garden_Manuals_2024_C | sort > remote_files.txt
# What's in your local folder
ls "/path/to/Macintosh_Garden_Manuals_2024_C" | sort > local_files.txt
# Show any differences
diff local_files.txt remote_files.txt
One important caveat: archive.org automatically generates several extra files on every item as part of the derive process — things like _meta.xml, _files.xml, a .torrent file, and sometimes a .sqlite file (used for full-text search on text items). These won’t exist in your local folder, so a plain diff will always show them as “extra” on the remote side, even when everything you actually uploaded is present and correct.
To get a clean comparison, filter these out of the remote list first:
ia list Macintosh_Garden_Manuals_2024_C \
| grep -vE '_meta\.xml$|_files\.xml$|\.torrent$|_archive\.torrent$|\.sqlite$' \
| sort > remote_files.txt
Now diff local_files.txt remote_files.txt only flags real discrepancies — files you expected to be there but aren’t, or vice versa — without the noise of archive.org’s own bookkeeping files.
Terminal output showing the upload resuming after a corrupted PDF was repaired
That’s it — a repeatable, scriptable way to get a whole library of files onto the Internet Archive.
Here’s the complete batch script with comments, kept here as a quick reference for future me (or anyone else following along):
#!/bin/bash
# ---------------------------------------------------------------
# Batch-uploads a set of folders to the Internet Archive, one
# folder per item. Each folder becomes its own archive.org item,
# using the folder name as both the identifier and the title.
# ---------------------------------------------------------------
# Parent directory containing all the subfolders to upload
BASE_DIR="/path/to/parent/folder"
# List every folder (inside BASE_DIR) that should become its own item
FOLDERS=(
"Folder_A"
"Folder_B"
"Folder_C"
)
# Loop through each folder and upload it as a separate item
for folder in "${FOLDERS[@]}"; do
# Pull out whatever comes after "YEAR_" in the folder name, just
# for use in the description text (e.g. "A" from "Manuals_2025_A")
letters=$(echo "$folder" | sed 's/.*[0-9]\{4\}_//')
echo "=============================================="
echo "Folder / Identifier: $folder"
echo "=============================================="
ia upload \
--retries=120 \
--sleep=120 \
-H "x-archive-keep-old-version:0" \
--checksum \
"$folder" \
"$BASE_DIR/$folder"/* \
--metadata="description:A short description mentioning $folder and items starting with $letters." \
--metadata="language:eng" \
--metadata="mediatype:texts" \
--metadata="title:$folder"
echo "Finished $folder"
echo ""
done
echo "All uploads complete."
How it works, piece by piece:
BASE_DIR — the parent folder holding all your subfolders. Every path in the script is built relative to this.FOLDERS array — the list of subfolder names to upload. Each one becomes a completely separate archive.org item.for loop — walks through the array one folder at a time, running a full ia upload for each before moving to the next. This is what makes the whole thing “batch” — you run the script once, and it works through the entire list unattended."$folder") — this, not the metadata block, is what actually sets the item’s identifier and permanent URL. It’s the folder name itself, reused as the identifier for simplicity and consistency."$BASE_DIR/$folder"/* — the wildcard that grabs every file in that folder (PDFs, images, zips, txt files, subfolders — everything) to include in the upload.--checksum — makes the whole script safely re-runnable. Files already uploaded and unchanged get skipped, so if a run gets interrupted (or a file needs fixing and re-uploading), you can just run the script again without duplicating work.-H "x-archive-keep-old-version:0" — tells archive.org not to preserve old versions of files if the same identifier/file is uploaded again later.--retries / --sleep — resilience settings so a flaky connection doesn’t kill the whole run; it’ll keep retrying a failed step rather than giving up immediately.echo lines — purely for readability in the terminal, so you can visually track which folder is currently being processed as the script runs.A good habit going forward: redirect the script’s output to a log file so you can search it for errors after a big run, rather than relying on scrollback:
./upload_all.sh 2>&1 | tee upload_log.txt
grep "error uploading" upload_log.txt