To update a file path in multiple files after moving a folder or drive, search the affected files for every form the old path can take and replace each with the new path. The easiest way is plain-text mode, where C:\Data\Projects is matched exactly as typed. Then run extra searches for the forward-slash form (C:/Data/Projects) and the doubled-backslash form used in JSON and many config files (C:\\Data\\Projects). If you use regex mode, remember that a backslash is an escape character, so C:\Data must be written C:\\Data. Search without match case, because Windows paths are not case-sensitive.
Below is how to find every variant, a single regex that handles all three slash styles at once, and the references that a text search cannot reach.
Step 1: find every form of the old path
The same folder can be written several ways, depending on the program that saved the file:
| Form | Example | Where you see it |
|---|---|---|
| Backslashes | C:\Data\Projects | Batch files, INI files, most Windows programs |
| Forward slashes | C:/Data/Projects | Cross-platform tools, PHP, Python, many build files |
| Doubled backslashes | C:\\Data\\Projects | JSON, JavaScript and C# strings, some config files |
| File URL | file:///C:/Data/Projects | HTML, XML, shortcuts saved as text |
| URL-encoded | C:/My%20Data/Projects | Paths with spaces inside URLs |
| Mapped drive or UNC | P:\Projects, \\fileserver\data\Projects | Shared folders |
| Environment variable | %USERPROFILE%\Documents | Scripts and shortcuts |
Start with a search, not a replace. Search for the most distinctive part of the path, for example just Projects near Data, and look at how it is written in each file type. The guide to finding every file that contains a word shows several ways to run that search on Windows.
Step 2: decide plain text or regex
Plain text (simplest)
Add one rule per form you found, all in plain-text mode with match case off:
C:\Data\Projects→D:\Work\ProjectsC:/Data/Projects→D:/Work/ProjectsC:\\Data\\Projects→D:\\Work\\Projects
Order matters here. Run the doubled-backslash rule before the single-backslash rule, or the single one will match the middle of the doubled form first and leave a mess. In practice, C:\Data does not appear inside C:\\Data because of the extra backslash after the colon, but making the more specific rule run first is a good habit.
Regex (one rule for all slash styles)
A single case-insensitive regex can cover the three common forms:
- Find:
C:(\\\\|\\|/)Data\1Projects\b - Replace:
D:$1Work$1Projects
The group (\\\\|\\|/) matches a doubled backslash, a single backslash or a forward slash, in that order of preference. \1 then requires the same separator later in the path, and $1 puts that same separator back in the new path. So C:/Data/Projects becomes D:/Work/Projects, and the JSON form keeps its doubled backslashes. The \b at the end stops it matching C:\Data\ProjectsOld. A path that mixes separators, such as C:\Data/Projects, is not matched, so search for that separately if your files contain it.
If backslash escaping is new to you, our guide to escaping special characters in regex explains why each backslash in the path becomes two in the pattern.
Step 3: watch the path boundaries
A path is a prefix of every path below it, which is usually what you want: changing C:\Data\Projects also updates C:\Data\Projects\2025\report.xlsx. The danger is sibling folders that share a starting name.
C:\Dataalso matches insideC:\Database. In regex, end the pattern with\b:C:\\Data\bmatchesC:\Data\xbut notC:\Database.\bstill allowsC:\Data-old, because a hyphen is not a word character. UseC:\\Data(?=[\\/"']|$)if names like that exist.- When the old path is a drive root such as
E:\, search forE:\with the backslash, notE:alone, or you will hit things like time stamps and IPv6 addresses.
Step 4: replace and verify
- Back up the files or commit them.
- Filter to the file types that hold paths: scripts, config, project files, HTML. Exclude logs, which record history.
- Run the replace, then search again for each old form. The count should be zero.
- Run the scripts or open the projects that use the paths. A missed reference usually shows up as a "file not found" error.
Bulk Replace lets you stack the plain-text rules or the single regex rule, filter to the right extensions, and see each changed path in a before/after diff before writing. Each file keeps its encoding, which matters for config files with a byte order mark, and every run is backed up so you can undo it in one click. If folder or file names also contain the old path segment, Bulk Replace can rename those in the same run.
References a text search cannot reach
Not every path lives in a plain-text file. These need separate handling:
| Where | Why text tools miss it | How to update |
|---|---|---|
| Windows shortcuts (.lnk) | Binary files; batch tools skip them | Right-click → Properties → Target, or recreate |
| Office documents (.docx, .xlsx) | Compressed XML inside a ZIP | Excel: Data → Edit Links; Word: edit the field or link |
| Registry | Not a file | Registry Editor → Edit → Find |
| Scheduled tasks | Stored by Windows | Task Scheduler → task → Actions |
| Environment variables such as PATH | Stored by Windows | Settings → System → About → Advanced system settings → Environment Variables |
| Databases | Not a file you edit directly | SQL UPDATE, with a backup |
Avoid the next path change
Once you have found every reference, consider making the next move easier:
- Use relative paths inside projects, so moving the whole project folder needs no edits.
- Use one variable in scripts, for example
$root = 'D:\Work\Projects'at the top, and build other paths from it withJoin-Path. - Use a mapped drive or a symbolic link.
mklink /D C:\Data\Projects D:\Work\Projectsin an administrator Command Prompt makes the old path point to the new location, which can buy time while you update files. - Keep the inventory. Save the list of files that contained the old path. It is your checklist next time.
If the path was part of a URL rather than a disk path, the job is closer to a domain move. See replacing an old domain name across website files for that case.
Frequently asked questions
Why does my Windows path not match in regex mode?
Backslashes are escape characters in regex. Write C:\\Data to match C:\Data, or use plain-text mode so the path is matched literally.
Do I need to change both slash styles?
Often yes. Many files store paths with forward slashes, and JSON stores backslashes doubled, so search for each form.
Is a path match case-sensitive?
Windows paths are not case-sensitive, but a case-sensitive text search is. Search without match case so C:\data and C:\Data are both found.
