File name matching
File name matching
This guide explains how to import a file whose name changes with each export, for example when your system adds a date or timestamp to every file it creates. Instead of a fixed file name, you enter a pattern. On each run, the import finds the files that match and imports one of them.
Where you can use it
Dynamic file matching is available for Data hub imports into item collections and Data hub catalogs.
Customer, event, and voucher imports use data imports, which have their own file matching options.
How matching works
When an import runs, it lists the files in the parent directory and checks each file name against your pattern:
- File names only: The pattern is checked against the file name, not the folder path. Files in subfolders aren't included.
- Anywhere in the name: A pattern matches if it appears anywhere in the file name. For example,
dailymatchesprefix_daily_2026-10-13.csv. To match the whole name, start the pattern with^and end it with$. - Case-sensitive:
feeddoesn't matchFeed_2026.csv. To ignore the letter case, start the pattern with(?i). - One file per run: If more than one file matches, the selection rule decides which one is imported.
Set up dynamic file matching
- Create or edit a file storage import.
- In Path to parent directory, enter the folder that contains your files.
- Under File matching, select Dynamic.
- Enter your pattern without enclosing slashes, for example
^catalog_\d{4}-\d{2}-\d{2}\.csv$. - Choose a Selection rule.
- Click Preview data. The preview shows which file was selected, so you can check that the pattern and selection rule pick the file you expect.
If the pattern isn't valid, the import can't be saved, and an error message shows which part to fix.
Write a pattern
Patterns use RE2 regular expression syntax.
- Don't add enclosing slashes, such as
/feed.csv/. The import can't be saved with slashes in the pattern. - Escape dots as
\.. An unescaped.matches any character, socatalog.csvalso matchescatalog_csv. - Lookaheads
(?=…), lookbehinds(?<=…), and backreferences such as\1aren't supported.
Examples
| Files in the parent directory | Pattern | Selection rule | Imported file |
|---|---|---|---|
catalog_2026-10-12.csv, catalog_2026-10-13.csv, readme.txt | ^catalog_\d{4}-\d{2}-\d{2}\.csv$ | Last alphabetically | catalog_2026-10-13.csv |
Feed_upper.csv, feed_upper.csv | (?i)^feed_upper\.csv$ | Last alphabetically | feed_upper.csv (lowercase sorts after uppercase) |
prefix_daily_2026-10-13.csv, weekly_report.csv | daily | Last modified | prefix_daily_2026-10-13.csv |
products_export_8812.csv (uploaded first), products_export_8813.csv (uploaded last) | ^products_export_\d+\.csv$ | Last modified | products_export_8813.csv |
Choose a selection rule
If more than one file matches your pattern, the selection rule decides which file is imported:
- Last modified: Imports the file with the most recent modification time on the server. Use this rule when the newest upload is always the one you want. It's the recommended rule for full feeds.
- Last alphabetically: Imports the file that comes last when the matching names are sorted alphabetically. Use this rule when the file name shows which file is newest, for example with a date in the name.
NoteLast alphabetically compares file names character by character, so
feed_9.csvcomes afterfeed_10.csv. To keep the order correct, pad numbers with leading zeros (feed_09.csv) and write dates as year, month, day (2026-10-13).
What happens on each run
- A file matches: The selection rule picks one file, and the import runs on that file.
- No file matches: The run fails, and you get a failure notification. Your item collection or catalog isn't changed. This applies to scheduled runs and manual runs.
- The same file is still the newest match: The import doesn't keep a record of the files it has already imported, so it imports the same file again. To avoid this, move each file out of the parent directory after it's imported, for example to an archive subfolder. Files in subfolders aren't matched, so they aren't picked up again.
To stop using a pattern, switch File matching back to Fixed and enter the exact file name. The import then uses only that file.
Limitations
- Each run imports one file. Importing several matching files in one run isn't available.
- Imports start on a schedule. Starting an import automatically when a new file is uploaded isn't available yet.
- The parent directory path is static. It can't contain a pattern.
- Files in subfolders aren't matched.
- The import doesn't track which files it has already imported.
Move a pattern from a legacy catalog import
If you're recreating a legacy catalog import in Data hub, check your file name pattern before you copy it over:
| Legacy catalog imports | Data hub imports | What to do |
|---|---|---|
| New file uploaded trigger | Not available yet | Use a repeated schedule. |
| Remembers imported files | Doesn't track imported files | Move imported files out of the parent directory, or make sure a new file is in place before each scheduled run. |
| Selection rules: All, Last modified, Last alphabetically, Not imported yet | Last modified, Last alphabetically | If you used All or Not imported yet, choose the rule that picks the file you need. |
| Supports lookaheads, lookbehinds, and backreferences | RE2 syntax doesn't support them | Rewrite the pattern without them. |
The pattern is enclosed in slashes: /catalog_[0-9]+\.csv/ | No slashes: catalog_[0-9]+\.csv | Remove the slashes. |
Related articles
Updated about 1 hour ago

