How-to & Workflow

How to Rename Files in Multiple Folders (Recursively, in One Pass)

Renaming a single folder is easy. The problem starts when the files are scattered across a tree of subfolders, or when the same filename, scan_001.pdf, repeats inside dozens of them. Opening each folder by hand does not scale, and dragging everything into one directory flattens the structure you may need to keep. This guide shows three ways to rename files across a whole folder tree in a single pass: recursive command line scripts, GUI tools with a subfolder mode, and content-aware renaming that names each file by what is inside it regardless of where it sits. Each approach preserves the folder layout, and each one lets a preview run before anything is committed.

Why Cross-Folder Renaming Needs a Different Approach

A normal batch rename works on the files sitting in one directory. Point it at a folder that contains twenty subfolders and, by default, it touches nothing inside them. To reach the whole tree, the tool has to recurse, which means it walks into every subfolder, and every subfolder below that, applying the same rename rule as it goes.

Recursion introduces three concerns that a single-folder rename never has to think about. First, structure: the goal is almost always to rename files in place, not to flatten a tidy tree into one crowded directory. Second, scope: a deep tree often contains subfolders that should be left alone, an archive, a node_modules, a backup, so the recursion needs a way to exclude them. Third, safety: a scripted recursive rename runs across hundreds of files at once and, on the command line, there is no undo button. A mistake in the pattern hits the entire tree before anyone notices.

The three methods below handle all three concerns, they differ mainly in how much manual pattern work they demand and whether they can name files by their actual content.

Method 1: Recursive Renaming on the Command Line

The command line is the fastest route when the new names follow a predictable rule, a find-and-replace on the existing name, a prefix, a sequence number, and when the person running it is comfortable reading a preview before committing.

On Windows PowerShell, Get-ChildItem walks the tree and pipes each file into Rename-Item. To lowercase every file across a tree and preview the result first, run Get-ChildItem -Path C:\Scans -Recurse -File | Rename-Item -NewName { $_.Name.ToLower() } -WhatIf. The -Recurse flag is what makes it cross subfolders, and -WhatIf is the critical part: it prints exactly what would be renamed without changing a single file. Remove -WhatIf only once the printed plan looks correct. To swap text in every name, for example turning scan into invoice, use -NewName { $_.Name -replace 'scan','invoice' }. Because Rename-Item renames a file where it already lives, the folder structure is preserved automatically.

The classic CMD equivalent uses FOR /R, which loops recursively from a starting folder. A command such as FOR /R C:\Scans %f IN (*.pdf) DO REN "%f" "renamed_%~nxf" walks every subfolder and renames each PDF in place. CMD has no built-in preview, so it is safer to first run the same loop with ECHO REN instead of REN to print the intended commands.

On macOS or Linux, find does the recursion. find ./Scans -type f -name '*.pdf' -exec rename 's/scan/invoice/' {} + hands every matching file to the rename utility, which applies a Perl-style substitution across the whole tree. Where the rename command is not installed, a shell loop does the same job: for f in $(find ./Scans -type f -name '*.pdf'); do mv "$f" "$(dirname "$f")/new_$(basename "$f")"; done. Note the use of dirname, it puts each renamed file back into its own folder rather than moving it. To preview, echo the mv line instead of running it.

Command line recursion is powerful and free, but it renames purely from the old filename. It cannot look inside a scanned PDF, so it cannot turn scan_001.pdf into a name that reflects the document, that is the limit of every rule-based approach.

Method 2: GUI Tools With a Subfolder Mode

For anyone who wants a visible grid and a live preview rather than a scripted command, dedicated renamers handle recursion through the interface.

Bulk Rename Utility, on Windows, has a Subfolders option in its file tree. Enabling it loads every file beneath the selected top folder into one flat list, while each file keeps its real path. The rename rules, replace, numbering, case, trim, apply across the whole tree at once, and the New Name column updates live so the outcome is visible before the Rename button is pressed. Files stay in their original folders.

Advanced Renamer works the same way through its Add folders dialog, which offers a recursive Include subfolders switch. It builds a rename batch across the tree, shows a before-and-after preview for every file, and supports methods stacked in sequence. Both tools let specific subfolders be excluded, either by not adding them or by filtering them out of the loaded list, which covers the archive-and-backup exclusion concern.

GUI subfolder mode is the sweet spot for structured, rule-based renames across a tree, no scripting, a real preview, structure preserved. Like the command line, though, these tools read filenames and file metadata, not the content of the document itself.

Method 3: Content-Aware Renaming Across the Tree

The methods above all share one ceiling: they can only rearrange the names that already exist. When the existing names carry no meaning, a tree full of scan_001.pdf, IMG_2231.pdf, and Document(3).pdf, a find-and-replace just produces differently meaningless names.

Unlike rule-based renamers that only see filenames, renamer.ai reads the actual document content (OCR + AI vision) to generate descriptive names automatically. Pointed at the top of a folder tree with recursion enabled, it opens each file wherever it lives, reads the invoice number, vendor, date, or subject inside it, and writes a descriptive name using the chosen template, then leaves the file in its original subfolder. A scattered tree of look-alike scans comes out as a set of consistent, self-describing names in a single pass, without anyone writing a pattern.

This is the approach to reach for when the files are documents, scanned invoices, contracts, receipts, statements, rather than assets with names worth preserving. For a deeper walkthrough of the content-reading step itself, see the guide on how to rename scanned PDF files.

Recursive rename methods compared

PowerShell / find (recursive script)Bulk Rename Utility (subfolder mode)Content-aware (renamer.ai)
Recurses subfolders?Yes, via -Recurse or findYes, Subfolders optionYes, points at the top folder
Preview before running?Yes, -WhatIf or echoYes, live New Name columnYes, proposed names shown
Reads file content?No, filename onlyNo, filename and metadataYes, OCR + AI vision
Best forRule-based renames when scripting is comfortableRule-based renames with a visual previewMeaningless names that need real content-based names

A Recursive Before and After

Consider a Scans folder with two subfolders, one named 2024 and one named 2025, and inside each of them a file called scan_001.pdf, scan_002.pdf, and scan_003.pdf. Six files, but only two distinct names repeated across the tree. A rule-based recursive rename can prefix them, but it cannot tell the 2024 copy of scan_001.pdf from the 2025 copy by anything except the folder it sits in.

Before, across the tree: /Scans/2024/scan_001.pdf, /Scans/2024/scan_002.pdf, /Scans/2024/scan_003.pdf, /Scans/2025/scan_001.pdf, /Scans/2025/scan_002.pdf, /Scans/2025/scan_003.pdf.

After a content-aware pass, each file is named from what it contains while staying in its own folder: /Scans/2024/acme-invoice-4471-2024-03-12.pdf, /Scans/2024/northwind-receipt-2024-05-08.pdf, /Scans/2024/citypower-statement-2024-09-30.pdf, /Scans/2025/acme-invoice-5120-2025-02-19.pdf, /Scans/2025/northwind-receipt-2025-04-22.pdf, /Scans/2025/citypower-statement-2025-08-11.pdf.

The tree is untouched, nothing was flattened or moved, and every file now carries a unique, sortable name that no filename-only tool could have produced from the identical scan_001.pdf inputs.

Scattered Scans Still Need OCR

The reason a filename-only tool hits a wall on a folder tree of scans is the same reason it hits a wall on a single folder of them: a scanned PDF is an image of a page, and its text is not stored as characters the computer can read. Optical character recognition is the step that converts that image into words, so scan_001.pdf becomes a document whose invoice number, vendor, and date can actually be read.

Spreading those scans across many subfolders does not change the requirement, it multiplies it. Every branch of the tree holds documents that are opaque to a rule-based rename, and each one needs OCR before a meaningful name can be generated. A content-aware pass applies that recognition to every file in the tree at once, which is why a recursive, content-based rename is the only route that produces descriptive names for scattered scans rather than just tidier versions of the same unreadable filenames.

Frequently Asked Questions

How do I rename files in multiple folders at once?

Use a tool that recurses into subfolders. On the command line, PowerShell's Get-ChildItem -Recurse piped into Rename-Item, or find on macOS and Linux, walks the whole tree. In a GUI, enable the Subfolders option in Bulk Rename Utility or Include subfolders in Advanced Renamer. All of them rename files in place, so the folder structure is preserved rather than flattened.

How do I recursively rename files with PowerShell?

Pipe a recursive Get-ChildItem into Rename-Item. For example, Get-ChildItem -Path C:\Scans -Recurse -File | Rename-Item -NewName { $_.Name.ToLower() } lowercases every file across the tree. The -Recurse flag reaches every subfolder, and Rename-Item renames each file where it already sits, so nothing is moved. Always add -WhatIf first to preview the result.

How do I rename files across subfolders without moving them?

Choose a rename that operates in place. Rename-Item, FOR /R with REN, and the rename utility called through find all change the filename without touching the path, so the file stays in its own subfolder. In a shell loop, use dirname to write each renamed file back to its original directory. GUI tools like Bulk Rename Utility keep the path automatically in subfolder mode, so the tree is never flattened.

Can I rename files across many folders by their content?

Yes. Content-aware renaming reads what is inside each file rather than its old name. Unlike rule-based renamers that only see filenames, renamer.ai reads the actual document content (OCR + AI vision) to generate descriptive names automatically. Pointed at the top of a folder tree, it names every file by its content in one pass and leaves each one in its original subfolder, which is the only way to give meaningful names to scattered look-alike scans.

How do I preview a recursive rename before it runs?

Use the preview built into the method. In PowerShell, add -WhatIf to print exactly what would be renamed across the tree without changing anything, or echo the command in CMD and shell loops. GUI tools show a live before-and-after list, and content-aware tools display the proposed names first. A scripted recursive rename has no undo, so back up the tree before committing.