Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk7 min

How to Name Screenshots from URLs in a Batch Capture

Build readable screenshot filenames from URL hosts and paths, prevent collisions with indexes or hashes, and save a batch with Playwright.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build each screenshot filename from the URL’s host and path, then add an index or short stable hash so distinct URLs cannot silently overwrite one another. For example, https://example.com/products/blue-mug?ref=email can become example-com-products-blue-mug--001.png. Decide whether query parameters distinguish pages, sanitize the resulting name for your operating system, and make the extension match the image format you actually save.

Choose a filename pattern before capturing

A useful batch filename is readable, predictable, and unique within the output directory. A practical pattern is host-path--index.png or host-path--short-hash.png. These are implementation choices, not a naming standard prescribed by Playwright.

As an Amazon Associate I earn from qualifying purchases.

  • Host and path: Make the page recognizable at a glance, such as example-com-products-blue-mug.
  • Index: Add a zero-padded position such as --001 when the input order is meaningful and stable.
  • Short hash: Add a short stable hash of the full URL when distinct input URLs might normalize to the same readable slug.
  • Run timestamp: Add a run identifier when each batch should be archived rather than overwrite the previous capture.

Choose one policy for reruns: stable names overwrite known artifacts, while timestamped names preserve separate runs and consume more storage.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decide how URLs become safe, useful names

Normalize host and path

Start with the hostname and path. Replace separators and characters awkward in filenames with a consistent delimiter, collapse repeated delimiters, and remove leading or trailing punctuation. For a root URL, use a clear label such as example-com-home rather than an empty path.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Sanitization rules differ across operating systems and filesystems. Keep names reasonably short, and avoid assuming that every URL character is safe in a path. If a URL contains non-ASCII characters, choose explicitly whether to preserve readable Unicode or normalize it to a restricted character set.

Set a query-string and fragment policy

Query strings can identify different content variants, but often contain tracking values that make filenames noisy. Include only query values that materially change the page being captured. If meaningful parameters are omitted, different pages may receive the same slug, so append an index or hash derived from the full URL or from the meaningful parameters.

Fragments are not sent to the server in an HTTP request, but client-side applications may use them to select content. Decide whether fragments matter for your capture workflow; include them in uniqueness logic if they can change what the browser renders.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

Prevent collisions deliberately

Two different URLs can reduce to the same host-and-path slug—for example, when query parameters are removed. Detect duplicate output paths before starting the capture batch, or add an index or short stable hash. Do not rely on the filesystem’s overwrite behavior to resolve collisions: one page’s screenshot could replace another’s.

Generate names and save screenshots with Playwright

Playwright’s page screenshot API accepts a caller-selected path, and supports full-page capture with fullPage: true (Playwright screenshots documentation). The following Node.js example makes a sanitized host-and-path slug, adds a stable short SHA-256 suffix based on the complete URL, and saves PNG files to a chosen directory.

import { chromium } from 'playwright';
import { createHash } from 'node:crypto';
import { mkdir } from 'node:fs/promises';
import path from 'node:path';

const urls = [
  'https://example.com/products/blue-mug?ref=email',
  'https://example.com/products/blue-mug?variant=large',
  'https://example.com/',
];

function filenameFor(rawUrl, index) {
  const url = new URL(rawUrl);
  const readable = `${url.hostname}${url.pathname}`
    .toLowerCase()
    .normalize('NFKD')
    .replace(/[\/]+/g, '-')
    .replace(/[^a-z0-9._-]+/g, '-')
    .replace(/-+/g, '-')
    .replace(/^[-._]+|[-._]+$/g, '')
    .slice(0, 100) || 'page';
  const hash = createHash('sha256').update(rawUrl).digest('hex').slice(0, 8);
  return `${String(index + 1).padStart(3, '0')}-${readable}--${hash}.png`;
}

await mkdir('screenshots', { recursive: true });
const browser = await chromium.launch();
try {
  const page = await browser.newPage();
  for (const [index, url] of urls.entries()) {
    const outputPath = path.join('screenshots', filenameFor(url, index));
    await page.goto(url, { waitUntil: 'networkidle', timeout: 60000 });
    await page.screenshot({ path: outputPath, fullPage: true });
    console.log(`${url} -> ${outputPath}`);
  }
} finally {
  await browser.close();
}

Install Playwright and its browser before running the script: npm install playwright, followed by npx playwright install chromium. Save the script as an ES module, for example capture.mjs, then run node capture.mjs. The example keeps the query string out of the readable portion but hashes the full URL, so those two sample product URLs still get different names. If a fragment changes client-rendered content, the hash already distinguishes it because it hashes the raw URL string.

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

For a different policy, change filenameFor: remove the hash for stable host-and-path names only if collisions are impossible or checked; omit the index when input order should not affect names; or add a batch timestamp when each run must be retained. If URLs can differ only by equivalent textual encodings, normalize them consistently before hashing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright CLI or Playwright Test when that fits the workflow

Playwright CLI

Playwright CLI accepts an explicit --filename=<f> option. Without one, its documented default is page-{timestamp}.{png|jpeg|webp} in the output directory; the CLI also shows custom names such as login-page.png and full-page.png (Playwright CLI screenshots and PDF commands). An explicit name is handy for one-off captures. For a batch, your loop or calling script should generate a distinct filename for each URL and pass it to the CLI rather than reusing one name.

Playwright Test snapshots

For screenshot assertions, configure Playwright Test’s snapshot path template to organize expected images by test directory, project, test file path, screenshot argument, and extension. This can separate browser-project baselines and keep snapshots near a stable test structure (Playwright API parameters: screenshot path templates). Templates organize test artifacts; they do not decide how an arbitrary URL should be sanitized or guarantee URL-derived uniqueness.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Match the extension to the captured format

Use a file extension that agrees with the emitted image format. Playwright CLI can infer format from the filename extension and otherwise defaults to PNG; its screenshot tooling documents PNG, JPEG, and WebP (CLI screenshot documentation; Playwright MCP screenshots tool). If your workflow writes JPEG or WebP, generate .jpg or .webp names accordingly rather than labelling the file .png.

Or skip the browser setup:

ScreenshotNeo can return the screenshot directly from one GET request; its parameter names also work with the names used by other screenshot APIs. For this URL, a caller can derive a filename using the same naming policy and save the response under it. See the ScreenshotNeo documentation for request options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Before capture, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Learn about ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot naming and batch failures

  • One image replaced another: The normalized names collided. Include a stable hash or index and check generated paths for duplicates before capture.
  • Names are unreadable or excessively long: Limit the readable host-and-path slug, replace awkward characters consistently, and put uniqueness in a short hash rather than copying the entire query string.
  • Different page variants share a filename: Identify the query parameters or fragment that change rendered content and include them in the naming input, or hash the full URL.
  • The image format and extension disagree: Set the output extension to the format actually produced by the capture command or API.
  • A navigation times out: Check that the URL is reachable from the machine running the browser and adjust the navigation timeout or wait condition for pages that keep network requests open. A timeout is a capture failure, not a filename-generation failure.
  • Repeated captures are hard to compare: Use deterministic names for the same inputs and capture settings. Add a run identifier only when retaining each batch separately is intended.

Validate the naming function before a large run

Test representative URLs before launching the full batch: a root path, a trailing slash, a query string, a fragment, non-ASCII text, and two distinct URLs that could normalize to the same slug. Confirm the generated paths are unique, legal for the target filesystem, and carry the correct image extension. Keep the URL-to-filename mapping in logs or a manifest when the output directory alone is not enough to trace an image back to its source.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Frequently Asked Questions

Does Playwright choose URL-based filenames automatically?

No URL-derived naming algorithm is documented here. Generate the name in your script and pass the path to the screenshot API or an explicit CLI filename.

Should query parameters go in screenshot filenames?

Include only parameters that distinguish rendered variants. If you leave them out, use an index or hash to prevent different URLs from sharing a filename.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How can I keep screenshots from different test projects separate?

Use Playwright Test’s screenshot path-template configuration, which includes project and test-related tokens.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.