Rename Files
Renames files using find and replace (plain text or regular expression), a prefix and suffix, or an exact list of old and new names, as renamed copies or in place.
Rename Files works out a new name for every file in the input, then either writes renamed copies to the run's files folder (keeping the folder structure) or, with Change files in place on, renames the files where they are. Every file gets a report row with its old and new name and what produced the new name.
There are two ways to rename. Rules: find and replace runs first, then the prefix and suffix are added around the name. Mapping: a list of exact old name, new name pairs. A file on the mapping list uses the mapping only; the rules do not apply to it. All names are planned before anything changes, so clashes are found up front and nothing is ever overwritten.
Use it when
- Files need a standard naming convention before production or upload, for example adding a matter prefix or removing
Draft. - You have a spreadsheet of current names and the names they should have, such as document IDs or exhibit numbers.
- Extensions need correcting across a set, for example
.jpegto.jpg.
How to run it
- Choose the folder as Input and an Output folder outside it.
- For rules, fill in find and replace, and/or prefix and suffix.
- For a list, paste two columns from Excel into mapping, or choose a CSV in mapping-file.
- Decide on number-collisions: off reports clashes as errors; on adds
_(1),_(2). - Leave Change files in place off to get renamed copies. Turn it on only if the input itself must be renamed; you will be asked to confirm.
- Click Run, read the notes, then click Open report and check the NewName column.
Settings
Every setting has the same help beside it in the app. On the command line, pass each as --name value; ltk help rename-files lists them.
Settings
| Setting | What it does | Type and default |
|---|---|---|
Find--find |
Text to find in each name (without the extension, unless Include extension is on). Leave empty to only add a prefix or suffix. Looks at the name without its extension unless include-extension is on. Every occurrence is replaced. If find, prefix, suffix and the mapping are all empty, the run stops with a message before anything happens. |
text empty |
Replace--replace |
What the found text is replaced with (empty removes it). With Regex, $1, $2… insert captured groups. | text empty |
Regex--regex |
Treat Find as a regular expression instead of plain text. Use $1, $2 in replace for captured groups, e.g. find ^photo (\d+)$ and replace IMG_$1. An invalid expression stops the run before it starts. An expression that takes too long on a name gives an Error row for that file. |
yes/nofalse |
Match case--match-case |
Find is case-sensitive. Off (default): 'draft' also finds 'Draft' and 'DRAFT'. Applies to plain text and regular expressions. Off by default, so draft also matches Draft and DRAFT. |
yes/nofalse |
Prefix--prefix |
Text added to the start of every name (after find/replace). | text empty |
Suffix--suffix |
Text added to the end of every name, before the extension (after the prefix). | text empty |
Include extension--include-extension |
Find/replace also looks at the extension (e.g. to change .jpeg to .jpg). Prefix and suffix always go around the name without the extension. Needed to change an extension. Prefix and suffix still go around the name without the extension. |
yes/nofalse |
Mapping--mapping |
Optional list of exact renames, one per line: old name, new name (comma or tab separated; paste two columns from Excel). An old name with its extension replaces the whole name; without an extension it replaces the name and keeps the extension. Listed files use the mapping instead of the rules above. One pair per line, separated by a comma or a tab; quotes are allowed for names containing commas. Blank lines, lines starting with # and a header line such as Old name, New name are skipped. Old names are matched without regard to case, and are names, not paths, so every file with that name in any sub-folder is renamed. doc1, First renames doc1.pdf to First.pdf; doc1.pdf, First.pdf matches the full name only. Bad lines, and names listed twice with different new names, are listed in errors.csv; the first entry is used. |
text (lines) empty |
Mapping file--mapping-file |
Optional CSV or text file with the same two columns (old name, new name). Combined with the mapping above. | file empty |
Number collisions--number-collisions |
When a new name is already taken (by another file or an earlier rename): Off (default) reports an Error and leaves the file as it is; On adds _(1), _(2)… to make it unique. A name is taken if another file in the same folder already has it, or an earlier file in this run was given it. A change of letter case only ( memo.txt to MEMO.txt) is not a clash. |
yes/nofalse |
Common settings
| Setting | What it does | Type and default |
|---|---|---|
Input required--input |
Folder (or single file) to read. It is opened read-only and never modified. | folder empty |
Output required--output |
Folder for reports. Must not be inside the input folder. Each run gets its own sub-folder. | folder empty |
Change files in place--in-place |
Off (default): changed copies are written to the output folder and the input is untouched. On: files in the input folder itself are renamed/moved, and every change is logged in the report. You will be asked to confirm. | yes/nofalse |
Recurse--recurse |
Include sub-folders. | yes/notrue |
Extensions--extensions |
Only process these extensions (e.g. .pdf, .docx). Empty means the tool's default set. | list empty |
Parallelism--parallelism |
Files processed at once. Use 1-2 for spinning disks or network shares. | number4 |
What you get
Each run creates its own folder inside the output folder, with the report rename-files.csv, errors.csv and manifest.json (see Run folders and manifests).
files\…: Copy mode only: every selected file, renamed or not, in the same folder structure, with its original timestamps. Files with an Error are not copied.rename-files.csv: One row per file: OldName, NewName, RenamedBy (Rules or Mapping), OldPath, NewPath, Action, Status (Renamed, Unchanged or Error), MD5 and Message.not-found.csv: Written when a mapping is used: mapping entries that matched no file.in-place-journal.csv: In-place runs only: each rename logged to disk before and after it is made.errors.csv: Files that could not be renamed and mapping lines that could not be used, with the reason.
Report columns
RelativePathOldNameNewNameRenamedByOldPathNewPathActionStatusMD5Message
Check the result
- Read the notes, especially how many mapping entries matched no file, then open
not-found.csv. - Filter the report on Status = Error. Common reasons are a name already in use, characters Windows does not allow, a name ending in a dot or space, or a reserved name such as
CON. - Check that the RenamedBy column shows Mapping for every file you expected the list to cover.
- Do a copy-mode run first and check the report. If the names are right, repeat it in place or use the copies.
- Rules and a mapping can be used in the same run: listed files take their mapped name and every other file gets the rules.
- The report's OldPath and NewPath give a complete record for reversing the change.
- In place renames the files in the input folder. Do not run it on original evidence. The run asks for confirmation, and from the command line it needs
--confirm-in-place. - A new name that contains
\or/is treated as invalid; this tool renames files and does not move them between folders.
From the command line
The command line is part of LitTechKit Pro. See Command line.
ltk run rename-files --input "D:\Matter\Production\Natives" --output "D:\Matter\Work" --mapping-file "D:\Matter\rename-list.csv"
Related tools
- Assign Document IDs: Renames files to document IDs in folder order: prefix + number (ABC0000001) or prefix/box/folder/page (ABC.5000.0001.0001), one number per document or per page. Report maps each ID to the original path and MD5. Copies by default, renames in place on request, or just previews.
- Flatten Folder Structure: Puts all files from sub-folders into one folder, renaming clashing names by number or by folder prefix. Copies to the output folder by default, or moves the files in place with a full change log.
- Delete By File Name: Removes files whose names are on a list (exact, without extension, or contains). By default copies everything else to the output folder; in place, matched files are moved to the run folder's removed folder, never destroyed.
- File Inventory: Lists every file with size, timestamps, attributes, hashes and detected file type, flagging extensions that don't match the content.