Crates.io | stdrename |
lib.rs | stdrename |
version | 1.3.0 |
source | src |
created_at | 2020-08-18 11:58:54.475143 |
updated_at | 2020-10-17 03:18:11.629146 |
description | `stdrename` is a small command line utility to rename all files in a folder according to a specified naming convention (camelCase, snake_case, kebab-case, etc.). |
homepage | |
repository | https://github.com/Gadiguibou/stdrename |
max_upload_size | |
id | 277832 |
size | 61,505 |
This small utility is designed to rename all files in a folder according to a specified naming convention (camelCase, snake_case, kebab-case, etc.).
It currently supports the following naming conventions:
Download the latest released file supported by your OS (shared library for Linux and .exe for Windows) and add it to your $PATH
.
On Linux you may need to make the shared library file executable with:
chmod +x stdrename
Install stdrename
using cargo with:
cargo install stdrename
The executable file can then be found in $HOME/.cargo/bin/stdrename
.
To make sure $HOME/.cargo/bin
is in your $PATH
use:
export PATH="$HOME/.cargo/bin:$PATH"
You must specify the naming convention you want to use with the appropriate flag. For example, this will rename all files in the current directory using the kebab-case naming convention.
stdrename -k
Here is the full list of naming convention flags that can be used:
Short | Long | Example |
---|---|---|
-c |
--camel |
camelCase.txt |
-k |
--kebab |
kebab-case.txt |
-p |
--pascal |
PascalCase.txt |
--screaming |
SCREAMING_SNAKE_CASE.txt |
|
-S |
--sentence |
Sentence case.txt |
-s |
--snake |
snake_case.txt |
-T |
--title |
Title Case.txt |
-t |
--train |
Train-Case.txt |
You can also specify a different folder to parse with a second argument e.g.:
stdrename -k ~/Pictures
To rename recursively, use the flag -r
or --recursive
e.g.:
stdrename -kr ~/Pictures
To rename directories as well, use the flag -D
or --dir
e.g.:
stdrename -kD ~/Pictures
By default, patterns in .gitignore
files, global gitignore files and git exclude files will be ignored as well if the directory is a git repository.
You may also add a .ignore
file with patterns to ignore in the file's directory and its subdirectories.
This file may use any of the glob patterns that can be used in a .gitignore
file. It is functionally the same, just with a different name e.g.:
Adding the following line in a new .ignore file in the same directory as stdrename will ignore all files with the extension .py
and all files in the subdirectory ./target/
when renaming.
# ./.ignore
# ignore all files ending with .py
# ignore all files in /target and its subdirectories
*.py
/target
You may even add a second .ignore
file in a subdirectory e.g.:
# ./subdir1/.ignore
# match .py files despite previous instructions
# ignore .txt files in this directory and all subdirectories
!*.py
*.txt
All files in that directory and all sub directories will then reinclude .py files and ignore .txt files.
If you'd like to use global ignore patterns specific to stdrename, you can do so by creating an "ignore
" (notice this one does not start with a ".") in the following location:
On Windows: %USERPROFILE%\AppData\Local\stdrename\"
On Unix based systems (e.g. MacOS or GNU Linux):
$HOME/.config/stdrename/
This file follows the same pattern matching principles as other .gitignore
or .ignore
files and has a lower precedence than all other sources of ignore rules.
--text
modeText mode allows for either piping through stdin, e.g.:
echo 'Hello World' | stdrename --text -k
or interactive use, e.g.:
stdrename --text -s
reallyCreativeProgramName.js
really_creative_program_name.js
PYTHONISTA_BANANA.py
pythonista_banana.py
This is really just a normal sentence
this_is_really_just_a_normal_sentence
Either way, the program terminates and stops reading as soon as it encounters an empty line.
To suppress the exit message (if piping stdout to another file for example) add the -q
or --quiet
flag.