Skip to content

Commit

Permalink
Rename -b flag to -d
Browse files Browse the repository at this point in the history
  • Loading branch information
jpikl committed Mar 29, 2021
1 parent c7851c7 commit e1d0188
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Output of `--help-filters` flag has more readable layout.
- `-T, --no-trailing-delimiter` flag was renamed to `-L, --no-print-end`.
- `-s, --fail-at-end` flag was renamed to `-F, --fail-at-end`.
- `-b, -diff` flag was renamed to `-d, --diff` flag.

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ find -iname '*.jpeg' | rew 'img_{C}.{e|l|r:e}'
Rew is also distributed with two accompanying utilities (`mvb` and `cpb`) which move/copy files and directories, based on `rew` output.

```bash
find -iname '*.jpeg' | rew 'img_{C}.{e|l|r:e}' -b | mvb
find -iname '*.jpeg' | rew 'img_{C}.{e|l|r:e}' -d | mvb
```

## Documentation
Expand Down
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ find -iname '*.jpeg' | rew 'img_{C}.{e|l|r:e}'
Rew is also distributed with two accompanying utilities (`mvb` and `cpb`) which move/copy files and directories, based on `rew` output.

```bash
find -iname '*.jpeg' | rew 'img_{C}.{e|l|r:e}' -b | mvb
find -iname '*.jpeg' | rew 'img_{C}.{e|l|r:e}' -d | mvb
```
2 changes: 1 addition & 1 deletion docs/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

```bash
find -name '*.jpeg' | xargs rename .jpeg .jpg # Rename *.jpeg files to *.jpg
find -name '*.jpeg' | rew -b '{B}.jpg' | mvb # Same thing using rew + mvb
find -name '*.jpeg' | rew -d '{B}.jpg' | mvb # Same thing using rew + mvb
find -name '*.jpeg' | rew -q 'mv {} {B}.jpg' | sh # Same thing using rew + mv + sh
```

Expand Down
14 changes: 7 additions & 7 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ls | rew '{a}' # Paths are read from standard input
Rename all `*.jpeg` files to `*.jpg`.

```bash
find -name '*.jpeg' | rew -b '{B}.jpg' | mvb -v
find -name '*.jpeg' | rew -d '{B}.jpg' | mvb -v
```

Same thing but we use `rew` to generate executable shell code.
Expand All @@ -24,37 +24,37 @@ find -name '*.jpeg' | rew -q 'mv -v {} {B}.jpg' | sh
Make backup copy of each `*.txt` file with `.txt.bak` extension in the same directory.

```bash
find -name '*.txt' | rew -b '{}.bak' | cpb -v
find -name '*.txt' | rew -d '{}.bak' | cpb -v
```

Copy `*.txt` files (keep directory structure) to the `~/Backup` directory.

```bash
find -name '*.txt' | rew -b "$HOME/Backup/{p}" | cpb -v
find -name '*.txt' | rew -d "$HOME/Backup/{p}" | cpb -v
```

Copy `*.txt` files (flatten directory structure) to the `~/Backup` directory.

```bash
find -name '*.txt' | rew -b "$HOME/Backup/{f}" | cpb -v
find -name '*.txt' | rew -d "$HOME/Backup/{f}" | cpb -v
```

Same thing but we append randomly generated suffix after base name to avoid name collisions.

```bash
find -name '*.txt' | rew -b "$HOME/Backup/{b}_{U}.{e}" | cpb -v
find -name '*.txt' | rew -d "$HOME/Backup/{b}_{U}.{e}" | cpb -v
```

Flatten directory structure `./dir/subdir/` to `./dir_subdir/`.

```bash
find -mindepth 2 -maxdepth 2 -type d | rew -b '{D}_{F}' | mvb -v
find -mindepth 2 -maxdepth 2 -type d | rew -d '{D}_{F}' | mvb -v
```

Normalize base names of files to `file_001`, `file_002`, ...

```bash
find -type f | rew -b '{d}/file_{C|<3:0}{E}' | mvb -v
find -type f | rew -d '{d}/file_{C|<3:0}{E}' | mvb -v
```

Print the first word of each line with removed diacritics (accents).
Expand Down
4 changes: 2 additions & 2 deletions docs/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Apart from this (standard) mode, there are also two other output modes.
Such output can be processed by accompanying `mvb` and `cpb` utilities to perform bulk move/copy.

```bash
find -name '*.jpeg' | rew -b '{B}.jpg' | mvb # Rename all *.jpeg files to *.jpg
find -name '*.txt' | rew -b '{}.bak' | cpb # Make backup copy of each *.txt file
find -name '*.jpeg' | rew -d '{B}.jpg' | mvb # Rename all *.jpeg files to *.jpg
find -name '*.txt' | rew -d '{}.bak' | cpb # Make backup copy of each *.txt file
```

## 🌹 Pretty mode
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ input | rew [options]
Use `-b, --diff` flag when piping output to `mvb`/`cpb` utilities to perform bulk move/copy.

```bash
rew [options] [--] [pattern] -b | mvb
rew [options] [--] [pattern] -d | mvb
```

Use `-h` flag to print short help, `--help` to print detailed help.
4 changes: 2 additions & 2 deletions src/bin/cpb/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use termcolor::ColorChoice;
<src_path_N
>dst_path_N
Such input can be generated using accompanying `rew` utility and its `-b, --diff` flag:
Such input can be generated using accompanying `rew` utility and its `-d, --diff` flag:
$> find -name '*.txt' | rew -b '{}.bak' | cpb # Make backup copy of each *.txt file
$> find -name '*.txt' | rew -d '{}.bak' | cpb # Make backup copy of each *.txt file
Each pair of source and destination path must be either both files or both directories. Mixing these types will result in error.
Expand Down
4 changes: 2 additions & 2 deletions src/bin/mvb/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use termcolor::ColorChoice;
<src_path_N
>dst_path_N
Such input can be generated using accompanying `rew` utility and its `-b, --diff` flag:
Such input can be generated using accompanying `rew` utility and its `-d, --diff` flag:
$> find -name '*.jpeg' | rew -b '{B}.jpg' | mvb # Rename all *.jpeg files to *.jpg
$> find -name '*.jpeg' | rew -d '{B}.jpg' | mvb # Rename all *.jpeg files to *.jpg
Each pair of source and destination path must be either both files or both directories. Mixing these types will result in error.
Expand Down
2 changes: 1 addition & 1 deletion src/bin/rew/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub struct Cli {

/// Enable diff output mode
#[clap(
short = 'b',
short = 'd',
long,
conflicts_with = "pretty",
help_heading = OUTPUT_HEADING,
Expand Down

0 comments on commit e1d0188

Please sign in to comment.