---
title: "How to Sync Any Files in Any Folder with the WordPress Media Library"
url: "https://wpimportexport.com/how-to-sync-any-files-in-any-folder-with-the-wordpress-media-library/"
description: "Register server-folder files in the WordPress Media Library. Rescan for new arrivals, skip duplicates and use an AI agent with step-by-step examples."
type: post
published: 2026-07-28T14:37:09+00:00
modified: 2026-11-14T10:33:40+00:00
categories: ["Media Import", "Video Lessons"]
tags: ["FTP Upload WordPress", "Import Export by RockStarLab", "Media Hash Index", "Real Media Library", "Register FTP Files", "WordPress Duplicate Media", "WordPress Import Export Plugin", "WordPress Media Folder Sync", "WordPress Media Library", "WordPress media sync"]
docs_topics: ["Media workflows"]
---

# How to Sync Any Files in Any Folder with the WordPress Media Library

Files copied into `wp-content/uploads` by SFTP or a hosting file manager sit on the server, but WordPress doesn’t list them in the Media Library. **Import Export by RockStarLab → Import → Media Sync** scans a folder inside `wp-content/uploads`, shows the files and registers them. Choose **MD5 Hash**, **Skip Duplicates** and **Keep in current directory** to add new files while leaving them where they are.

That suits a folder that receives new documents, photos or downloads over time. Media Sync creates the attachment records, so you can select the files in the editor and manage their titles and captions.

Here, “sync” means scanning and registering selected files. It is not a continuous folder watcher or a two-way mirror that deletes attachments when their source files disappear. For the initial upload step, follow [registering FTP/SFTP uploads in the Media Library](https://wpimportexport.com/how-to-register-ftp-sftp-uploaded-files-in-the-wordpress-media-library/). The steps below cover choosing a folder, repeat scans and checking what was added.

## Prepare the folder and choose the right workflow

Use a folder inside your WordPress uploads directory, such as `wp-content/uploads/field-guide/`. In the plugin, its relative path is simply `field-guide`. You can include nested folders or limit the scan to that one directory. “Any folder” here means a supported folder within uploads, not arbitrary directories elsewhere on the server.

| Your files are… | Use this workflow |
| --- | --- |
| Already in an uploads subfolder | Media Sync: scan and register them. |
| Available as URLs on another website | [Import Media from a CSV or Excel file](https://wpimportexport.com/import-wordpress-media-library-files/). |
| Registered on another WordPress site, with captions and alt text to preserve | [Export and import attachment metadata without duplicates](https://wpimportexport.com/how-to-export-and-import-wordpress-media-files-without-duplicates/). |
| Already in this Media Library, and you need an inventory | [Export the media records and original URLs](https://wpimportexport.com/export-wordpress-media-library-to-csv-excel/). |

Finish uploading files before starting the scan. Confirm that WordPress can read them and that their types appear in the screen’s allowed-upload list. A custom extension filter narrows the selection; it does not grant permission to upload a file type WordPress disallows. Keep server backups and private documents outside a public media workflow.

## 1. Prepare duplicate detection

Before the first large synchronization, open **Import Export by RockStarLab → Tools → Media Hash Index** and build the index for existing library files. Wait for it to finish. Hashes let the plugin recognize identical file bytes even when someone has renamed a copy. Indexing does not merge or delete duplicate attachments already in the library.

A hash is not visual image recognition. Recompressing, resizing or editing an image changes its bytes, so an image that looks similar may be a separate file. Use a small initial selection to confirm the duplicate policy suits your collection.

## 2. Open Media Sync and scan your folder

Open the plugin’s **Import** screen and select **Media Sync**. Enter `field-guide` in **Folder Path**, or use **Browse** to choose the folder. Use `/` only when you intentionally want to scan the uploads root.

Enable **Scan Subdirectories** if files in child folders belong in the same operation. Choose All Media Types, Images, Videos, Audio, Documents or Custom Extensions. For a custom list, enter extensions without dots, such as `jpg, png, pdf`. Click **Scan Folder**.

![Media Sync folder path and file type controls in WordPress](https://wpimportexport.com/wp-content/uploads/2026/11/folder-media-sync-folder.webp)

_Choose a specific uploads subfolder and the file types you want to register._

## 3. Review the candidate files

The scan shows filenames, paths and sizes. Clear the checkboxes for files that should not become attachments. Check the directory as well as the filename, particularly when subfolders contain similarly named assets.

**The scan total is not the number of new attachments.** Previously registered originals can still appear in the results. Duplicate handling is applied when the synchronization processes your selection.

![Media Sync scan results listing documents in a server folder](https://wpimportexport.com/wp-content/uploads/2026/11/folder-media-sync-scan.webp)

_Review the selected files before choosing how to handle duplicates._

## 4. Set duplicate handling and file operations

| Setting | Useful choice for repeat scans | What to consider |
| --- | --- | --- |
| Duplicate Detection | MD5 Hash | Compares file content; build the index for existing media first. |
| Duplicate Handling | Skip Duplicates | Retains the existing attachment instead of creating another copy. |
| File Operation | Keep in current directory | Registers the file at its existing uploads location. |
| Batch Size | Start small | Larger files and image metadata generation require more processing time. |

**Filename Match** and **Filesize + Filename** are also available. Names alone do not prove that two files have the same content. For a recurring folder containing renamed copies, the hash option gives a more useful comparison.

The other duplicate actions are **Overwrite Existing** and **Rename and Import**. Use them only when replacement or another attachment is intentional. Skip Duplicates is the appropriate starting point for adding new arrivals.

**Copy Files** retains the source while creating a copy; **Move Files** removes the original from its source location. If existing pages already use the folder URLs, keeping files in their current directory avoids moving those source files. Do not assume that moving files rewrites links throughout your content.

![Hash duplicate detection, Skip Duplicates and Keep in current directory settings](https://wpimportexport.com/wp-content/uploads/2026/11/folder-media-sync-options.webp)

_Use hash matching and Skip Duplicates when rescanning a folder for new arrivals._

The optional **Real Media Library** checkbox organizes imported files into virtual folders when that plugin is active. It is separate from keeping files in their physical server directory. Ordinary registration works without it.

## 5. Start synchronization and verify the attachments

Click **Start Synchronization** and wait for completion. Read both Imported and Skipped totals. A run that imports zero files can be correct when every selected file already has a matching attachment.

![Media Sync completed with zero imported and four skipped files](https://wpimportexport.com/wp-content/uploads/2026/11/folder-media-sync-completed.webp)

_A repeat run can finish with all files skipped because they are already registered._

Open **View Media Library**, find an imported file and open its attachment editor. Check the filename, title and File URL. Open the file itself to confirm it loads; for images, also inspect the preview and generated sizes. Add an accurate alt description where appropriate rather than relying on a filename as a finished description.

![WordPress attachment editor showing a document registered in its original folder](https://wpimportexport.com/wp-content/uploads/2026/11/folder-media-sync-attachment.webp)

_The attachment’s File URL confirms that Keep in current directory retained the original location._

For a larger operation, keep the job result and review any failed items in [Jobs Log](https://wpimportexport.com/how-to-use-jobs-log-and-schedule-wp-import-and-export-jobs/). When the job completes, check its counters and open a few of the new attachments.

## 6. Rescan after adding new files

Suppose a folder initially contains two documents. After registering them, add a third document and a renamed copy of the first. Scan again with the same hash-based skip settings.

| File in the next scan | Expected action |
| --- | --- |
| First original, unchanged | Skip its existing attachment. |
| Second original, unchanged | Skip its existing attachment. |
| New document | Create one attachment. |
| Renamed copy with identical bytes | Skip the matching attachment by hash. |

After that run, an unchanged repeat should add no attachments. Compare the original attachment edit links or IDs when checking the result. Do not choose Rename and Import if your goal is to keep one record per identical file.

## What happens to WordPress thumbnails during a rescan?

WordPress can store several image sizes alongside an original. Media Sync excludes generated sizes it recognizes through attachment metadata, so those thumbnails do not become independent media items just because they are in the folder.

A name ending in `-300x200.png` is not enough by itself to establish that the file is a WordPress-generated thumbnail. An independently supplied image with that name can remain a valid candidate. If you copied files from another site without their attachment records, inspect the scan rather than assuming all old resized copies will be recognized.

![Folder scan showing an original image and an independently named image with dimensions in its filename](https://wpimportexport.com/wp-content/uploads/2026/11/folder-media-sync-generated-sizes.webp)

_Review original files; known generated sizes are excluded using attachment metadata._

## Sync a media folder through an AI agent

Connect your agent using the [WordPress Abilities API and AI-agent setup guide](https://wpimportexport.com/how-to-use-the-wordpress-abilities-api-with-ai-agents-exports-imports-content-sync-and-backups/). Use the connection for the site that actually contains the folder. The agent should discover the available abilities and read their input schemas before executing the task.

The folder abilities work with files already present inside uploads. They do not transfer a folder from your computer by SFTP. Start with a read-only inventory:

> On my connected WordPress site, inspect the Media Hash Index status and scan the uploads-relative folder field-guide, including subfolders. List the candidate files and their sizes. Fetch all pages if the scan is paginated. Do not import, move, overwrite or delete anything yet.

Relevant abilities are `rsl-ie/media-hash-stats`, `rsl-ie/media-hash-build`, `rsl-ie/media-browse-folders` and `rsl-ie/media-scan-folder`. Building the hash index is a separate preparation step when the inventory shows it is needed.

Once you have reviewed the files, give a bounded execution prompt:

> Register the files we selected from field-guide in the Media Library. Keep them in their current directory, detect duplicates by hash and skip matches. Use a small batch size. Do not overwrite existing attachments or move source files. Start the media synchronization, poll it until complete and report created, skipped and failed counts, attachment IDs and any errors.

The agent calls `rsl-ie/media-sync-start` with the selected uploads-relative paths, then polls `rsl-ie/media-sync-status`. A scan response does not create attachments, and a pending job is not a completed import. Open the resulting attachments in the WordPress admin to confirm the files and URLs.

For example, the execution settings for two reviewed documents are:

```
{
  "folder_path": "field-guide",
  "selected_files": [
    "field-guide/collection-index.txt",
    "field-guide/november-field-guide.txt"
  ],
  "sync_options": {
    "duplicate_check": "hash",
    "duplicate_handling": "skip",
    "file_operation": "keep",
    "batch_size": 3
  }
}
```

Replace those paths with the exact paths returned by your scan. For the next delivery of files, use:

> Rescan field-guide and register the new arrivals using the same keep, hash and skip settings. Compare the result with the previous attachment inventory. Tell me which files were created and which matched existing attachments. Leave existing captions and file locations unchanged.

## Troubleshooting folder synchronization

| Symptom | What to check |
| --- | --- |
| No files found | Uploads-relative path, recursive setting, extension filter and readable files. |
| A file appears in the scan again | This is a candidate list. Read the skipped/imported outcome after processing. |
| A renamed copy imports again | Confirm hash detection and the existing index. Compare file bytes; a re-encoded image is a different file. |
| Old thumbnails appear as candidates | Check whether local attachment metadata exists for those generated files. Deselect unwanted copies. |
| An attachment exists but its file fails to load | Check its actual File URL and source file. Keep the files at registered locations. |
| An agent job stays pending | Check WordPress background processing and Jobs Log; do not keep starting duplicate jobs. |

Once the collection is registered, you can [export selected attachments](https://wpimportexport.com/export-selected-files-wordpress-media-library/) for a focused inventory or use the full media export guide to prepare a transfer.

## Video walkthrough

**Interface note:** This video was recorded with an earlier interface. Use the current screenshots and written steps above for menu locations and options.

[Video: Media Sync video walkthrough (earlier interface)](https://www.youtube.com/watch?v=fZ__TGJZ3c0)

## Frequently asked questions

### Does Media Sync watch the folder continuously?

No. Run a scan and synchronization when you want to register files. This workflow is not a continuous watcher or a two-way deletion mirror.

### Can I scan folders outside wp-content/uploads?

The folder workflow operates inside the WordPress uploads directory. Use an uploads-relative path such as field-guide, and optionally include its subdirectories.

### Why do existing files appear in the scan results?

Scanning lists candidate files. Duplicate detection and your skip, overwrite or import choice determine what happens during synchronization.

### Will renamed copies create duplicate attachments?

With a prepared hash index and Skip Duplicates, identical file bytes can match an existing attachment even when the filename changes.

### Does Media Sync register every WordPress thumbnail?

Known generated sizes are excluded using attachment metadata. Review files copied from another site if that metadata is missing.

### Do I need Real Media Library?

No. It is optional for virtual-folder organization. You can register files and keep their physical directory without that plugin.

### Can an AI agent perform the same synchronization?

Yes. After connecting the site, the agent can scan the folder, start a synchronization for selected files and poll the result. Verify the resulting attachments in the WordPress admin.
