Batch rename/rename simulator for multiple files | ZeroTools

Paste newline-separated file names to preview replacement, regex, numbering, and case conversions. Inspect names for collisions and export Bash or PowerShell scripts. Verify outputs and back up data before execution.

Loading tool interface...

When to use this tool

Back to the tool ↑

Preview changes from text replacement, regular expressions, numbering, and case conversion.

Try it first

Replace document with doc in the initial document_01.txt example and check the before-and-after names.

Before you start

The tool previews names and can produce a script. Check the destination folder for collisions before running the script.

Local Browser Processing and Network Communication Notice

This tool's processing operates locally within your browser. Standard site assets, analytics, and advertisements may communicate separately. There are no guarantees.

ZeroTools: Browser Processing & Privacy

ZeroTools focuses on tools that process input on your device. Check each tool’s scope and limitations before use.

Processing and privacy policy
Chapter 1

Non-destructive preview using only file names

This tool operates entirely on file name strings in the browser for non-destructive simulation. You can paste candidate file names into the left-hand input area one per line, or choose multiple files using the file picker button.

Even when files are selected via the file picker, the implementation only reads each File object's name property; it does not read file contents, modify files, or rename anything directly on your disk from within the browser.

Input lines are split supporting both Windows-style CRLF and macOS/Linux-style LF line breaks. Blank lines containing only whitespace are excluded from processing.

However, if an existing file name has leading or trailing spaces, the tool does not silently strip them or alter the name. Instead, such whitespace is flagged as an issue during subsequent validation checks so that you can verify your intent.

The "Rename simulator" on the right displays three columns: line number, before change, and after change. Lines whose names are modified by the current rule highlight the altered text, while lines that do not match the conditions keep their original names.

For example, given the initial sample names document_01.txt and document_02.txt, specifying the search string document and replacement doc displays doc_01.txt and doc_02.txt.

At this stage, nothing has changed on your actual storage. You can inspect all rows visually first, and then either copy the updated name list or save an execution script in this two-step workflow.

Chapter 2

Four renaming rules and extension handling

"String replacement" replaces all occurrences of the specified search string within each file name. For instance, replacing document with doc in document_document.txt produces doc_doc.txt.

Because it searches for exact literal characters rather than regular expressions, periods and parentheses do not need special escaping.

When the search string is empty, no changes are made.

"Regular expression" uses browser JavaScript regular expressions with the global flag. For example, searching for photo_(.*) with replacement image_$1 constructs new names using captured segments from matches like photo_holiday.png.

Backreferences such as $1 and $2 reuse captured parenthesized groups. If the regular expression syntax is invalid, the preview is cleared and script export is disabled rather than silently reverting to original names.

Complex expressions can easily match unintended ranges, so it is best to verify results on a few sample lines before applying them broadly.

"Assign a sequential number" combines a prefix, start number, number of digits, and suffix based on input order. With start number 1, 3 digits, and prefix file_, names become file_001, file_002, and so forth.

For names containing a period like photo.jpg, the portion after the final period is retained as the extension, yielding file_001.jpg.

For archive.tar.gz, only .gz is treated as the extension, producing file_001.gz. If you need to preserve compound extensions, choose string replacement or regular expression instead.

"Case" converts the base name to all lowercase or all uppercase while preserving the extension after the final period. Converting My.Photo.JPG to lowercase yields my.photo.JPG, leaving .JPG intact.

Dotfiles with only a leading period such as .gitignore do not have an extension separated; sequential numbering treats them as extensionless names, and case conversion applies across the entire name.

Chapter 3

Validation for names, duplicates, and collisions before saving

Even when a preview is displayed, the results cannot always be exported directly into an execution script. The script save buttons are disabled if no lines change, if a regular expression is invalid, or if input validation fails.

Because the interface does not automatically truncate filenames, append numbers, or display an on-screen error summary list, inspect the input, applied rules, and preview table to resolve collisions or illegal characters manually.

For each individual original and target name, the tool checks for empty names, ., .., leading or trailing whitespace, trailing periods, path separators, control characters, and illegal Windows characters.

Windows reserved device names beginning with CON, PRN, AUX, NUL, COM1 through COM9, or LPT1 through LPT9 are also flagged.

In addition, curved smart quotes that PowerShell treats as quote characters are rejected to prevent ambiguity in generated code. These checks represent conservative safeguards ensuring identical candidate lists work across both Bash and PowerShell rather than exhaustive OS limits.

Across the entire list, duplicate original names and duplicate target names are checked in a case-insensitive manner. The tool blocks not only situations where two original files map to the same target name, but also chained renames where a target name matches an original name on another line (such as shifting a.txt to b.txt and b.txt to c.txt).

It does not support complex circular swaps requiring intermediate temporary names, allowing only collision-free single-pass operations.

Candidate renames that only change letter casing, such as Document.txt to document.txt, are also blocked from saving. Whether case differences are distinguished depends not only on the operating system but also on underlying file system configurations.

This restriction does not assume data loss will occur, but serves as a conservative safeguard to prevent discrepancies when running the same script across different environments.

Chapter 4

Quoting and overwrite prevention in Bash scripts

Once all checks pass, you can save rename_files.sh for macOS and Linux. Only lines with actual changes are included in the output.

The script specifies Bash and sets set -e, ensuring execution terminates immediately if any command returns a failure status.

File names are enclosed in shell single quotes, with any single quotes inside names escaped by closing the quote, inserting an escaped literal quote, and reopening the quote.

This ensures spaces, dollar signs, and command substitution syntax are treated strictly as literal file names. All relative paths are prefixed with ./, preventing names starting with hyphens like -n from being misinterpreted as mv command options.

Before performing any mv operations, the script verifies in advance that all source targets exist as regular files and that no destination files or symbolic links already exist.

If even a single check fails, the script exits before renaming any files. Once pre-checks pass, files are renamed using mv -n to avoid overwriting existing destinations.

After each rename, the script verifies that the original path no longer exists, stopping immediately if it does.

The saved shell script should be placed in the same folder as the target files and executed from a terminal in that directory using bash rename_files.sh.

Because files downloaded from a browser might not possess execute permissions, passing the script explicitly to Bash avoids permission issues.

Open the script in a text editor to verify that the listed source and destination names match your preview before running it.

Chapter 5

Literal path handling in PowerShell scripts

For Windows environments, the tool saves a rename_files.ps1 PowerShell script rather than a legacy batch file. Batch files introduce complex escaping challenges when safely embedding arbitrary characters such as percent signs into script variables.

The generated PowerShell script is saved with a UTF-8 BOM and CRLF line breaks to ensure character encoding compatibility in Windows PowerShell, though display and execution across all terminal configurations cannot be unconditionally guaranteed.

At the beginning of the script, $ErrorActionPreference is set to Stop, and Set-Location $PSScriptRoot switches the working directory to the folder containing the script.

File names are enclosed in single-quoted strings with internal single quotes doubled. Both Test-Path and Rename-Item utilize the -LiteralPath parameter so that characters like square brackets are treated as literal path components rather than wildcards.

As with the Bash script, the script first verifies that all original files exist and that none of the destination paths exist. If any condition fails, execution halts with throw, and Rename-Item commands run sequentially only after all checks pass.

Each Rename-Item invocation includes -ErrorAction Stop. If system execution policies or organizational device management settings block running .ps1 scripts, do not attempt to bypass security policies; instead, follow your administrator's approved procedures.

Chapter 6

Execution procedures and recovery preparation for partial interruptions

In-browser validation and script-level pre-checks are designed to catch foreseeable naming conflicts and avoid overwriting existing files identified at configuration time.

However, a time gap exists between initial pre-checks and individual rename operations. The script cannot prevent third-party applications from creating files, locking targets, or altering access permissions in the interim, nor does it provide atomic transactional locking across the file system.

If a permission error or conflict occurs during execution, the script stops at that point. Renames completed prior to the failure are not automatically rolled back, leaving some files with new names and others with old names.

In this partial state, running the same script again may fail pre-checks because original files no longer exist under their initial names.

This design prevents unchecked compounding failures, but does not provide automatic recovery.

For important files, always duplicate the target folder to another location first to create a restorable backup. Next, inspect the script against the preview table and test execution on a small set of disposable copies.

During execution, ensure cloud sync utilities and other applications accessing the files are paused, and verify file counts and sample files afterward.

If an error occurs, inspect the folder alongside the script rather than repeatedly re-running it. Combining browser preview, export validation, script pre-checks, and user backups represents the intended operational safeguard.

Frequently Asked Questions (FAQ)

A.
No. The tool reads names via file selection or newline-delimited text, verifies updated names in the preview, and exports shell or PowerShell scripts. It does not modify files directly on your computer.
A.
You can choose from string replacement, JavaScript regular expressions, sequential numbering, and case conversion. Case conversion preserves the file extension.
A.
Duplicate names and invalid OS characters are validated, disabling script export if issues are detected. The tool does not display an on-screen error list or modify filenames automatically, so inspect the preview table and applied rules to resolve duplicate or invalid names manually. Always back up files beforehand.
A.
No. The script verifies source and destination files beforehand to avoid overwriting existing files, but execution may halt midway due to permission errors or runtime conflicts. Always test on disposable copies and keep backups.