Files

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.

Free Command line: rename-files Version 1.0

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

How to run it

  1. Choose the folder as Input and an Output folder outside it.
  2. For rules, fill in find and replace, and/or prefix and suffix.
  3. For a list, paste two columns from Excel into mapping, or choose a CSV in mapping-file.
  4. Decide on number-collisions: off reports clashes as errors; on adds _(1), _(2).
  5. 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.
  6. 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

SettingWhat it doesType 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/no
false
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/no
false
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/no
false
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/no
false

Common settings

SettingWhat it doesType 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/no
false
Recurse
--recurse
Include sub-folders. yes/no
true
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. number
4

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).

Report columns

Check the result

Tips
  • 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.
Watch out for
  • 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