mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-10-26 13:55:28 +03:00
268201e4ac
[Generated diff](https://www.diffnow.com/report/xmq4f) for command because move broke it. - No `file` prefix similar to other [filesystem commands](https://www.nushell.sh/commands/categories/filesystem.html) - Input paths instead of directory param for filters or globbing - Record closure param with original path (`$in` is still stem) - `--verbose` table output - `--no-exectute` for dry run with `--verbose` - Shorthand flags - Parallel renaming for large directories - More tests @amtoine Request feedback 🙏🏼 Happy to revise ot revert anything! ```console ❯ bulk-rename -h Rename bulk input files in parallel using a closure. The reason behind this command is quite simple: - Sometimes one receives a bunch of files with integer ids: 1, 2, 3, ... - These ids come rarely with padding... i.e. 1 instead of 001 when there are 3-digit ids - This means that file with id 9 will be sorted way after file with id 1000 This command allows to do such a task! Examples: Rename `.mise.toml` files to `.mise.local.toml` recursively > glob **/.mise.toml | bulk-rename { str append .local } Rename files in `/foo` with a name that has an id to have 3 digits with 0-padding > ls /foo | bulk-rename { |path| if $path.input.type == file { $path.stem | parse "some_format_{id}" | get 0 | update id { fill --alignment r --character 0 --width 3 } | $"some_format_($in.id)" } # else skip dirs } Usage: > main {flags} <update_stem> Flags: -v, --verbose - Show which files were renamed, if any -n, --no-execute - Do not make any changes; add --verbose to see what would be made whitespace bug: nushell/nushell#12264 -h, --help - Display the help message for this command Parameters: update_stem <closure()>: The code to rename the file stem: receives the old stem as input and a record param with both `stem` and `input` keys Input/output types: ╭───┬───────────┬─────────────────────────────────╮ │ # │ input │ output │ ├───┼───────────┼─────────────────────────────────┤ │ 0 │ list<any> │ nothing │ │ 1 │ list<any> │ table<old: string, new: string> │ ╰───┴───────────┴─────────────────────────────────╯ ``` |
||
---|---|---|
.. | ||
std-rfc | ||
tests | ||
nupm.nuon | ||
README.md |
std-lib candidate
This folder is where we can add scripts that might want to be in std-lib at some point. It can serve both as a holding place for scripts that are waiting on nushell changes, as well as a place to develop and discuss such scripts.