Deedpoll is a simple and useful CLI bulk/batch file renaming utility. It exists to bring the simplistic but powerful renaming model of GUI utilities like Linux Mint's Bulky and Thunar Bulk Rename to other systems in a maximally portable way.
Deedpoll is made with Lua and should run in any Lua 5.1 or later interpreter, including LuaJIT. It requires LuaFileSystem.
Usage: deedpoll [MODE] [PARAMETERS] [OPTIONS] [FILES]
[MODE]
accent (a) Removes accents in the file name.
delete (d) Delete characters between specified positions.
first (f) Makes first character uppercase.
insert (i) Insert text into filename.
lower (l) Changes names to lower case.
replace (r) Replace text in filename.
title (t) Changes names to title case.
upper (u) Changes names to upper case.
[PARAMETERS]
FIND Find text for replace mode. Wildcards ? and * are supported.
TEXT Text for insert/replace mode. Use %n, %0n, %00n etc. to enumerate.
[OPTIONS]
-c/--case Enable case sensitivity in replace mode.
-d/--disallow Listed files are not processed from current directory.
-e/--exp Treat replace mode find strings as Lua patterns.
-f/--full Use full file list including hidden dotfiles.
-h/--help Show help text.
-i=/--inc= Increment step for %n patterns in insert/replace mode.
-m/--mock Mock run without changing files or confirmation prompt.
-n=/--name= [(b)ase/(e)xt/(f)ull] aspect of filename to change.
-o/--overwrite Enable overwrite for insert mode.
-p=/--pos= Start position for insert/delete.
-r/--recurse Recurse search for files. Directories are not renamed.
-s=/--start= Start number for incremented %n patterns.
-t=/--to= Position to delete to in delete mode.
-v/--version Show version information.
-y/--yes Rename files without confirmation step.
Default behaviour is to operate on basename, with all values set to 1.
Unless `--mock` or `--yes` are enabled, Deedpoll requires confirmation.
For `--pos`/`--to`, pre/postfix 'e' to the value to specify from the end.
To work with hidden dotfiles using `--full`, also set `--name=full`.
`--case` has no effect on Windows as the filesystem is case insensitive.
If no files are listed, the contents of the current directory will be used.
EXAMPLES
# Change whole filename including the extension to uppercase
deedpoll upper -n=full
# Delete characters from 2nd to 5th letter
deedpoll delete --pos=2 --to=5
# Insert "text {n}" at start, incrementing in 2's, no confirmation
deedpoll insert "text %n" -i=2 -y
# Replace "old" with "new" in current directory except for "old_ignore.txt"
deedpoll replace "old" "new" -d old_ignore.txt
In most terminals, Deedpoll's output is colourful:
- Directories are shown in bold blue, akin to
ls. - In the case where a rename does not cause a change, Deedpoll uses a cyan arrow instead of a yellow one.
- Parameter/option overviews and informational text use colours to make them easier to read.
Deedpoll does not heaviliy sanitise it's CLI arguments.
For example, deedpoll any will resolve to the remove accent mode, as the argument begins with a.
insert and replace mode require parameters. Parameters are expected as the immediate arguments after specifying the mode, and are not flagged like options.
Options are parsed as full words, e.g. -i 2 will not be parsed, you must use -i=2.
At this time, Deedpoll does not support regular expression find and replace. Other tools like f2, brename and rnr offer this in a much better capacity. Deedpoll exists to do simple renaming tasks with less mental effort than it would take to make a regular expression.
On the converse, Deedpoll enables the user to use Lua patterns, which are simpler albeit more limited (but still very capable).
Most systems should provide installable packages for Lua and LuaFileSystem. Releases offers the ready to run script with a shebang added that can be used directly, and placed with the user's other binaries.
Alternatively, use Deedpoll's custom Lua build system. Clone the source and use ./make && ./make install to install to /usr/local.
The second argument can be set with a different install prefix, e.g. ./make install ~/.local.
If you have a Lua installation with LuaFileSystem you will be able to run Deedpoll, but that is not simple for an end user. For development purposes, I've found the easiest way to achieve that is with MSYS2 and its dedicated packages.
For distribution, Deedpoll's build command for Windows grabs Lua from LuaBinaries, and precompiled LFS from the ZeroBrane Studio source.
It bundles everything into a folder and creates a batch file to start it. You can then drop this set of files somewhere on your PATH and use deedpoll.bat.
The build system makes bundles for Lua 5.2 and Lua 5.4, as the newer version's precompiled LFS fails to run on Windows XP.
Deedpoll includes its own "build" system and test suite created in Lua, contained across the make and tests.lua files.
Deedpoll and its make system use a forked version of ansicolors to provide colours, which is stored as git submodule under lib. ansicolors is embedded into Deedpoll when the Unix-like script is built to avoid it being a external dependency.
Most of Deedpoll's code is handwritten, but in cases where it isn't are clearly commented in the source. Such snippets include:
- Code directly translated from Linux Mint's Bulky (Python) to Lua.
- Snippets from the internet, those snippets have citations and license information within the source.
- Some snippets are from LLMs, e.g. the search AI's that are hard to avoid. Each LLM is asked if its code can be incorporated into a MIT licensed project.
As far as I see it, ONLY the snippet and its modifications are under the source's license. The rest of the code it MIT Licensed. If you are the license owner and wish to contest this, please open an issue or contact me.
The make system offers the following options:
- build (default) - Create the "built" versions of Deedpoll into build/
- install - Install to system, requires
buildto have been run previously. - uninstall - Uninstall from system. Note that the make system does not remember custom prefixes.
- test - Run the test suite. Pass
-Vor--verboseto see Deedpoll's output for the tests. - clean - Delete build/ and any lingering test files generated from running tests.
New tests are added to tests.lua with the test{} function.
They are simply Lua tables detailing aspects of the test, like so:
-- Template for Deedpoll's tests.
test{
name = 'Descriptive name for the test.',
cmd = 'deedpoll [MODE] [OPTIONS]',
files = {
'filenames_to_pass_at_cli (optional).txt'
},
input = {
'starting_filename.txt'
},
expected = {
'expected_file_name.txt'
}
}- Remove/replace last CC BY-SA snippet and any other ambiguous ones. I don't like the whole recurse mode code anyway, could be much cleaner.
- Extract renamers as a separate library that extends the string library. Maybe add other functions too, like Solar2D's "python style" string library.
- Date/Time renamers.
- Make upper/lower etc. modes support diacritics.
- Apply additional colors to files, e.g. green for executables and red for .zips etc.
- Support custom renamers, where user writes a custom Lua function of the form:
return function(str) -- their rename logic -- str:delete(1, true, 3) -- Can use existing renamers return str end
- Find out why delete mode tests fail only on Windows XP (7 and later are fine).
- Add option so output can be grid aligned:
| ORIGINAL | AFTER | STATUS | | ------------- | ------------ | ------- | | file | new | CHANGED | | file long.txt | new long.txt | CHANGED | | new | new | SAME |
- For leading paths and recurse mode, use
treestyle output:. ├── renamed-01.txt ├── renamed-02.txt ├── renamed-03.txt └── one ├── renamed-01.txt ├── renamed-02.txt ├── renamed-03.txt └── two ├── renamed-01.txt ├── renamed-02.txt ├── renamed-03.txt └── three ├── renamed-01.txt ├── renamed-02.txt └── renamed-03.txt - UTF-8 awareness. Should we make Lua5.3 the minimum?
- Display number of files and directories.
- Make argument parsing more standardised and sanitised.
- Might move from LuaFormatter to Stylua, and try to fix all Selene/Luacheck warnings.
- Icon, badges for README, all that fancy whatnot.