How to Overwrite Existing Screenshot Files
Replace a screenshot safely on Windows, macOS, Cypress, Unity, scripts, or ScreenshotNeo while keeping a stable filename.
Direct answer: save the new capture to the existing file’s folder with the exact same filename and extension, then accept the replacement prompt. A screenshot shortcut may create a new time-stamped file or copy pixels to the clipboard, so the overwrite happens during the save operation. In scripts, write to the same path, such as with open(path, 'wb') or Cypress’s overwrite: true.
1. The overwrite rule
An overwrite is determined by the complete destination path. Match the folder, filename, extension, and encoded format.
- Confirm the resolved folder, including the drive, volume, project root, or synced directory.
- Use the same base filename.
- Keep the extension consistent with the image format.
Save a backup or use a temporary filename if the old image must be recoverable. Before confirming replacement, check the full path shown by the save dialog. Renaming capture.jpg to capture.png changes the name, not the encoded format.
2. Windows Snipping Tool
- Capture with Snipping Tool.
- Open the capture from the completion notification and edit it if needed.
- Select Image Save.
- Browse to the existing image’s folder and enter its exact filename and extension.
- If Windows asks whether to replace the file, verify the path and accept replacement.
Microsoft’s Snipping Tool guidance covers capture, editing, and saving. The exact collision dialog can differ by Windows version and file picker, so treat the path and filename shown in your dialog as authoritative.
Print Screen and clipboard captures
Print Screen copies pixels to the clipboard; it does not target an existing file. Paste into Paint, an image editor, or another application, then use that application’s Save or Save As workflow with the old path and filename.
3. macOS Screenshot
macOS normally saves keyboard screenshots to the Desktop with a date-and-time name such as Screen Shot [date] at [time]. Screenshot’s Options menu can change the save location. To replace a chosen image, open the capture in Preview or another editor and save it to the earlier file’s folder and exact name.
- Capture with
Shift-Command-3,Shift-Command-4, or Screenshot. - Open the result in Preview.
- Choose File → Save or Export.
- Set the destination and old filename.
- Accept replacement when prompted.
On supported Macs running macOS Tahoe 26 or later, Screenshot Options can choose SDR (PNG) or HDR (HEIF). Select the format that matches the file being replaced; changing only the extension does not convert image data.
4. Automated screenshots with a stable filename
Cypress
Cypress creates unique screenshot filenames by default. Set its documented overwrite option when a test should keep one file:
Cypress.Screenshot.defaults({
overwrite: true
})
// A later cy.screenshot('home') can replace the existing image.
Use a deterministic name and directory. Keep overwriting disabled when historical artifacts are needed for review.
Unity
using UnityEngine;
public class Capture : MonoBehaviour
{
public void Save()
{
ScreenCapture.CaptureScreenshot('artifacts/current.png');
}
}
ScreenCapture.CaptureScreenshot overwrites the target when it already exists. On Windows Editor, macOS Editor, and other non-mobile platforms, a relative path is relative to the Unity project directory, the folder containing Assets. Mobile path rules differ.
Portable shell replacement
set -eu
new='capture-new.png'
dest='public/images/home.png'
tmp='${dest}.tmp'
cp -- "$new" "$tmp"
mv -f -- "$tmp" "$dest"
Writing a temporary file in the destination directory and renaming it after completion prevents readers from seeing partially written bytes. Keep the old file until the new one is complete.
5. Format, path, and safety checks
| Check | Why it matters |
|---|---|
| Exact path | Cloud-sync folders, project roots, and mobile sandboxes can resolve differently. |
| Extension and encoded format | Viewers and build tools may reject bytes that do not match the extension. |
| Permissions and locks | Read-only folders, open editors, or antivirus locks can block replacement. |
| Backup or version control | An overwrite removes the previous bytes. |
| Downstream caches | Browsers, CDNs, and service workers may continue serving the old image. |
For a web asset, keep the URL stable and invalidate the relevant cache after replacing the file. For shared files, use a temporary file and rename it into place.
6. Troubleshooting
A new file appears beside the old one
The application generated a unique or time-stamped name. Use Save As, a fixed Cypress name, Unity’s target path, or a script that writes the intended destination.
The old image is unchanged
Check the folder, write permission, modification time, and whether you are viewing a synced or cached copy.
The save dialog has no Replace button
Some dialogs silently require deleting the old file; others show a separate confirmation. Verify the path first and keep a backup when recovery matters.
The image will not open
The extension may not match the encoded format, or the writer may have been interrupted. Export in the desired format and publish through a temporary file plus rename.
Unity wrote somewhere unexpected
Resolve relative paths from the project directory on desktop platforms. Log the computed path during development; mobile platforms use different storage rules.
Cypress still keeps multiple files
Confirm Cypress.Screenshot.defaults({ overwrite: true }) runs before capture and that the name and folder are identical on every run.
The replacement is correct locally but stale online
A browser, CDN, service worker, or image proxy may cache the old response. Purge or revalidate that cache, or publish a versioned URL.
7. Or skip the browser setup
For repeatable captures, ScreenshotNeo can write a response directly to the file you replace. It returns PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation for parameters.
curl -G 'https://api.screenshotneo.com/v1/shot' -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get('https://api.screenshotneo.com/v1/shot', params={'access_key': 'YOUR_API_KEY', 'url': 'https://stripe.com'}, timeout=90)
r.raise_for_status()
open('shot.webp', 'wb').write(r.content)
const fs = require('node:fs/promises');
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
Change each output path to your stable filename. ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000.
Create a free ScreenshotNeo account and keep your output filename under your control.
8. Performance, reliability, and cost
- Performance: use element capture when a full page is unnecessary and choose a cache TTL for unchanged pages.
- Reliability: validate HTTP status and content type, write to a temporary file, then rename. Inspect
X-Page-VerdictandX-Billedbefore publishing a ScreenshotNeo response. - Cost: local, Cypress, and Unity captures have no ScreenshotNeo API charge. ScreenshotNeo bills only clean shots; cache hits and failed or unusable loads are free. Plans are Free 1,000/month, Starter $5/3,000, Growth $15/15,000, Pro $39/60,000, Scale $99/250,000, and Business $249/1,000,000. Yearly billing gives two months free.
9. Checklist
- Identify the exact destination path.
- Match filename and extension to the intended format.
- Back up or commit the old image when rollback matters.
- Capture and write to that path.
- Confirm replacement and check modification time or checksum.
- Refresh downstream caches if needed.
10. FAQ
Does Print Screen overwrite a file?
No. It places the capture on the clipboard; an editor must save it.
Will macOS Screenshot reuse my previous filename?
Its documented default is a new date-and-time filename. Save or export to the old path.
Can I overwrite a PNG with a JPEG?
Only if the consuming application accepts the new format. Keep the extension and encoded bytes consistent.
How do I preserve one URL while updating the image?
Write the new bytes to the same path, then invalidate browser or CDN caches as needed.


