Batch Rename Images by Pattern with Numbered Filenames
Turn an ordered list of image filenames into a clean, consistent naming sequence before you rename, upload, archive, or publish the actual files.
Run — free
Supply a pattern with a counter placeholder, choose the starting number, and receive an explicit original-to-new filename mapping. The tool can preserve each original extension, reuse the original base name, and pad numbers for natural sorting. It only computes names: it never reads, uploads, moves, or modifies an image, so the proposed changes remain easy to review before any filesystem operation.
Build a clear image naming pattern
A good batch rename starts with a pattern that describes the collection rather than the camera or phone that created it. Use {counter} where the sequence number belongs, such as product-red-{counter}{ext}. Use {counter:3} when you want a fixed minimum width, producing 001, 002, and 003. The width may be from one to twenty digits, and a number that is already wider is never truncated. Add {ext} to keep each source filename's extension exactly as written, including its case, or use {name} when the original base name should remain part of the result. A pattern may contain the same placeholder more than once. Literal text stays unchanged. Because the result is a filename rather than a path, generated slashes and backslashes are rejected. This keeps the operation focused on naming and prevents a pattern from quietly changing directories. Review the returned mapping before applying it with a file manager, shell script, asset pipeline, or media library.
Control ordering, numbering, and duplicate safety
The input list defines the order. The first filename receives the value in start, the second receives the next integer, and processing continues without sorting or interpreting dates hidden in names. That makes the result predictable when your list already reflects a shoot order, spreadsheet order, selection order, or editorial sequence. The default starting value is 1, while 0 and other non-negative safe integers are accepted for systems that use zero-based numbering. Every generated filename is checked for collisions. A pattern without a counter is valid when other placeholders still create distinct names; for example, {name}-approved{ext} normally remains unique. However, if such a pattern would produce the same name for two images, the request fails and explains that a counter placeholder is missing. Patterns containing a counter are also checked, since repeated source entries or a pattern that ignores meaningful differences can still cause a collision in unusual cases. No partial mapping is returned when validation fails, so callers can treat a successful response as a complete rename plan.
Use the mapping safely in a real workflow
This capability computes a rename plan and deliberately does not touch files. Each result pairs the original filename with its proposed replacement, allowing a person or downstream program to inspect every change. That separation is useful for photographers preparing contact sheets, ecommerce teams normalizing product assets, developers organizing fixtures, and archivists creating stable sequences. Preserve {ext} when a batch mixes JPEG, PNG, WebP, or differently cased extensions; the placeholder copies the suffix from each individual source rather than forcing one format. Remember that renaming does not convert image data, so changing literal extension text would not change the underlying format. Inputs must be filenames, not directory paths, and filenames are limited to 255 characters. Batches may contain up to 10,000 items. For filesystem execution, consume the returned mapping with a tool that can detect existing destination files and perform a two-stage rename when old and new names overlap. The API charge is $0.002 per request. The same deterministic input always returns the same mapping, with no uploads, network calls, randomness, or time-dependent behavior.
What you can do with it
Sequence a photo shoot
Convert camera-generated names into a padded, ordered series while retaining every image's original extension.
Normalize product images
Create predictable storefront asset names for an ordered list of product angles and variants.
Preview an archive rename
Generate and review a complete old-to-new mapping before any archival files are changed.
FAQ
Which counter placeholders are supported?
Use {counter} for an unpadded number or {counter:width}, such as {counter:4}, for zero padding to a minimum width.
How do I preserve each image extension?
Put {ext} in the pattern. It copies the last extension, including the leading dot and original letter case.
Does this rename or upload my images?
No. It only returns a deterministic mapping from each original filename to a proposed new filename.
What happens if two new filenames are identical?
The entire request fails. If the pattern lacks a counter, the error specifically tells you to add a counter placeholder.
How much does the API request cost?
Each request costs $0.002, regardless of whether the counter starts at zero or uses padding.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/image/batch-rename-pattern \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"filenames":["IMG_4102.JPG","IMG_4103.JPG","IMG_4104.PNG"],"pattern":"gallery-{counter:3}{ext}"}'const res = await fetch("https://api.kit.forhosting.com/image/batch-rename-pattern", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"filenames": [
"IMG_4102.JPG",
"IMG_4103.JPG",
"IMG_4104.PNG"
],
"pattern": "gallery-{counter:3}{ext}"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/image/batch-rename-pattern",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"filenames": [
"IMG_4102.JPG",
"IMG_4103.JPG",
"IMG_4104.PNG"
],
"pattern": "gallery-{counter:3}{ext}"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/image/batch-rename-pattern", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"filenames":["IMG_4102.JPG","IMG_4103.JPG","IMG_4104.PNG"],"pattern":"gallery-{counter:3}{ext}"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"filenames":["IMG_4102.JPG","IMG_4103.JPG","IMG_4104.PNG"],"pattern":"gallery-{counter:3}{ext}"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/image/batch-rename-pattern", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"filenames": [
"IMG_4102.JPG",
"IMG_4103.JPG",
"IMG_4104.PNG"
],
"pattern": "gallery-{counter:3}{ext}"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "image.batch_rename_pattern",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_items | 10000 |
max_filename_chars | 255 |
max_pattern_chars | 255 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |