---
title: "How to Export and Import WordPress Media Files without Duplicates"
url: "https://wpimportexport.com/how-to-export-and-import-wordpress-media-files-without-duplicates/"
description: "Move WordPress media with a CSV, check for duplicate images by file hash, handle filename collisions and update captions through the admin or an AI agent."
type: post
published: 2026-06-18T18:38:18+00:00
modified: 2026-11-26T15:02:42+00:00
categories: ["Import Export Guides", "Media Import"]
tags: ["CSV import", "duplicate files", "media export", "media import", "WordPress media", "WordPress migration"]
docs_topics: ["Media workflows"]
---

# How to Export and Import WordPress Media Files without Duplicates

Export the original file URLs and attachment metadata to CSV, build the Media Hash Index on the receiving site, then import a small selection using **Media**. Before sending the rest, repeat one row with a revised caption. Open the same destination attachment and check that its caption changed while its ID and image stayed the same.

There are two decisions in a media migration. Does the destination already have the same file? If it does, whose title, alt text and caption should it keep? A file hash helps answer the first question. Your field mapping and choice of rows determine the second.

## Decide which media belongs in the import

| What you find | How to handle it |
| --- | --- |
| New image with a unique filename | Include its original file URL. Allow creation when no match is found. |
| Same file bytes under a different name | Index the destination first. Import one row and check which existing attachment receives the metadata. |
| Different images both called cover.png | Set the row aside. Give the incoming file a distinct, accessible source URL with a unique basename before using File URL matching. |
| Existing attachment with a carefully edited caption | Exclude that row if its metadata must stay untouched. If only the caption must stay, leave the caption column unmapped for that batch. |

For example, a red brochure cover and a blue winter edition may both be called `cover.png`. In version 2.1.9, File URL matching can pick an attachment by filename across sites. Two different domains or upload months do not rule out a collision. Give the incoming blue edition a name such as `riverside-winter-catalogue.png` and open its new URL before importing. Changing the filename in a spreadsheet without making the file available there produces a broken link.

A resized, cropped or re-encoded image can look identical and still contain different bytes. Decide whether to keep both versions. Building the index does not merge existing attachment records, remove files or change images embedded in published pages.

## Export the original file URLs and the fields you want to transfer

On the source site, open **Import Export by RockStarLab → Export** and select **Media**. Leave the filters empty for a full inventory or narrow the selection before choosing fields. For a hand-picked set, see the [selected media export guide](https://wpimportexport.com/export-selected-files-wordpress-media-library/).

Add **File URL**, **Title**, **Caption** and **Alt Text**. Add Description if the destination should receive it. File URL should point to the original file, not an attachment page or a thumbnail. A source attachment ID can help audit the export, but a different WordPress installation can already use that number for another item.

![WordPress media export with original file URL and attachment metadata](https://wpimportexport.com/wp-content/uploads/2026/11/media-dedupe-guide-export-fields.webp)

_Choose the fields you want the receiving library to use._

Choose CSV and enable **Include Header Row**. Start the export and use **Download Export File** when it completes. Each row describes one attachment. The CSV contains references to files, so keep the source host accessible until the destination has finished downloading them. The [Media Library export walkthrough](https://wpimportexport.com/export-wordpress-media-library-to-csv-excel/) covers the wider field selection and Excel output.

![Completed media export with the download control](https://wpimportexport.com/wp-content/uploads/2026/11/media-dedupe-guide-export-ready.webp)

_Download the finished inventory and keep an untouched copy._

## Prepare the receiving Media Library

[Back up the receiving site](https://wpimportexport.com/how-to-create-a-wordpress-website-backup-and-restore-it/) before a bulk metadata update. Keep a copy of its uploads as well as the database when you need to restore both files and attachment records. Take a destination media inventory so that you can compare file URLs, names and captions before and after the import.

Go to **Import Export by RockStarLab → Tools → Media Hash Index**. Click **Start scan**. The tool reads existing originals in batches and stores an MD5 fingerprint for each readable file. Review the **Indexed** and **Without a hash** counts at completion. If an original is missing from disk, resolve that item before relying on the index to find it. Refresh the index after replacing files outside WordPress.

![Media Hash Index on the receiving site with scan results](https://wpimportexport.com/wp-content/uploads/2026/11/media-dedupe-guide-hash.webp)

_Check the destination index before importing renamed copies._

If you already copied the binaries into uploads via SFTP and only need to register them, follow the [FTP/SFTP registration walkthrough](https://wpimportexport.com/how-to-register-ftp-sftp-uploaded-files-in-the-wordpress-media-library/). Use the CSV workflow below when you want to supply original URLs and editorial metadata together.

## Import a small CSV and review the mapping

1. Make a working copy of the export. Keep the header and one or two rows with known destination outcomes. Exclude name collisions until you have reviewed the actual originals.
2. On the receiving site, open **Import → Media**. Complete the backup step and upload the CSV.
3. In the preview, check that the URL, title, caption and alternative text occupy separate columns. Verify a caption containing punctuation. If several columns appear as one, correct the delimiter before proceeding.
4. Click **Auto Map** and review every pair. Map `file_url` to File URL, `post_title` to Title, `post_excerpt` to Caption and `alt_text` to Alt Text. Remove mappings for fields the receiving editor owns.

![Media import field mapping for a URL, title, caption and alternative text](https://wpimportexport.com/wp-content/uploads/2026/11/media-dedupe-guide-import-map.webp)

_Read the four source-to-destination pairs before opening import options._

A title is a Media Library label. A caption can appear below an image. Alt text describes the image for people who cannot see it. Keep these columns distinct. For files supplied by another system, the [CSV field mapping guide](https://wpimportexport.com/how-to-import-csv-files-into-wordpress-with-field-mapping/) explains manual mapping. The [media URL import tutorial](https://wpimportexport.com/import-wordpress-media-library-files/) covers downloading originals into WordPress.

## Choose what to update and verify the destination

Set **Check for Existing Items by Field** to **File URL** after checking filenames. Pick **Update** for matching rows whose mapped metadata should change. Pick **Create** under **If No Match Found** to bring in missing attachments. For a metadata-only batch, choose **Skip** under If No Match Found. Begin with a small batch while downloading large images and generating sizes.

![File URL matching and actions for matched and unmatched media rows](https://wpimportexport.com/wp-content/uploads/2026/11/media-dedupe-guide-import-options.webp)

_The two actions apply to different rows. Set both before starting._

Click **Start Import** and read the created, updated, skipped and failed counts. Open **Media → Library** and edit the resulting attachment. Compare the preview, title, caption, alt text and destination File URL. Keep the edit link so you can identify this exact record again. Check a different existing image as well if the library has similarly named files.

For a repeat run, keep the original source URL, change one mapped caption, import that row with Update, then reopen the saved edit link. The expected outcome is the new caption at the same attachment ID. Compare the original file if image identity matters. WordPress can generate multiple thumbnail files from a single attachment, so counting files in uploads is a poor way to count Media Library duplicates.

![Receiving WordPress attachment editor showing the blue Riverside cover](https://wpimportexport.com/wp-content/uploads/2026/11/media-dedupe-guide-blue-editor.webp)

_Open the destination attachment to check that the title belongs to the image you see._

If existing metadata must stay exactly as it is, remove the corresponding rows before running the job. In 2.1.9 a previously imported source URL can take an update path even when Skip is selected. If the counts or preview differ from your expectation, review the [Jobs Log](https://wpimportexport.com/how-to-use-jobs-log-and-schedule-wp-import-and-export-jobs/) and the affected attachment before importing a larger batch.

## Run the media import with an AI agent

Follow the [WordPress Abilities API and MCP setup guide](https://wpimportexport.com/how-to-use-the-wordpress-abilities-api-with-ai-agents-exports-imports-content-sync-and-backups/). Give the agent access to the intended sites and identify the destination explicitly. The free media workflow supports private file upload and an import job. Ask for the file and row counts at each step so the agent cannot silently expand a two-image example into a library-wide update.

Without the plugin, WordPress 7.1.5 gives a connected agent only three read-only abilities for site, user and environment information. The exports, imports and syncs in the requests below are abilities of Import Export by RockStarLab.

### Prepare a small inventory

> On the source site, discover the media export abilities. Prepare a CSV for only the attachments I select, with a header, original file URL, title, caption and alt text. On the receiving site, read the media hash index statistics. Show me any matching filenames and distinguish confirmed identical bytes from names that merely look alike. Do not import anything yet.

### Import approved rows

> On the receiving site, upload the approved CSV using upload-create, upload-chunk and upload-complete. Show the parsed header and the four field mappings. Exclude every row with an unresolved filename collision. Run rsl-ie/import-start for media with File URL matching, Update for matches and Create for missing files. Keep the same request ID if retrying this request. Poll job-get and report the processed, skipped and failed counts.

### Update one caption

> Import only the approved revised caption row. Use its original source URL and skip unmatched items. Use a new request ID for this new revision. Confirm the expected destination attachment ID before and after, read back the caption and open the image in its editor. Stop if the preview or attachment identity differs.

A completed job can tell you how many rows ran. The destination attachment tells you which picture received the caption. Check both before repeating the operation with the rest of the library.

## Frequently asked questions

### Does a WordPress media export CSV contain the images?

The CSV contains attachment fields and source file URLs. The receiving server needs access to those URLs to download missing originals.

### How does the Media Hash Index help with renamed files?

It stores MD5 fingerprints of readable attachment files. Identical bytes can match even when filenames differ. Resizing or re-encoding an image can change the fingerprint.

### Can two different images have the same filename?

Yes. Review both originals. For File URL matching in 2.1.9, give the incoming image a distinct accessible filename before importing it.

### How do I keep existing captions untouched?

Exclude existing rows from the import, or leave Caption unmapped when other fields on those rows should change. Keep a destination inventory to compare afterwards.

### How can I verify a repeat import without creating duplicates?

Save the destination edit link, change one caption in the source row and import it with Update. Reopen the same attachment ID and check its caption, preview and local file URL.

### Will scanning the hash index remove duplicates already in my library?

The scan reads files and refreshes their stored fingerprints. It does not merge attachment records or remove existing files.
