From 3f173d2335f415643cffc0fc1c0d34a907ee17f5 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 12 Dec 2023 16:26:05 +0000 Subject: [PATCH] Add README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d7dc213 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# nextfile + +`nextfile` is a Lua library used to generate the "next" filename in a sequence. + +## Installation +`nextfile` is published on [LuaRocks](https://luarocks.org), use `luarocks install nextfile` to install it. + +## Usage +The `nextfile` library actually contains two exported modules, `nextfile` and `prevfile`. +`prevfile` scans the files in a directory and returns the "most recent" filename according to a ["human sort"](https://en.wikipedia.org/wiki/Natural_sort_order) algorithm. +`prevfile` is also leveraged by `nextfile`, which then gives the "next file" according to the following rules: +- If the previous filename is entirely numeric, then the next file is the next number. For example, if the previous file were "500.jpg", then the next file would be "501.jpg". +- If the previous filename ends in a letter, then the next file will bump it to the next letter. For example, if the previous file were "200a.png", the next file would be "200b.png". + +By default, `nextfile` will give the next file the same file extension as the previous file; there is a second optional parameter for specifying the file extension.