edir 2.36__tar.gz → 2.37__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {edir-2.36 → edir-2.37}/PKG-INFO +68 -19
- {edir-2.36 → edir-2.37}/README.md +67 -18
- {edir-2.36 → edir-2.37}/edir.egg-info/PKG-INFO +68 -19
- {edir-2.36 → edir-2.37}/edir.egg-info/SOURCES.txt +2 -0
- edir-2.37/edir.egg-info/scm_file_list.json +9 -0
- edir-2.37/edir.egg-info/scm_version.json +8 -0
- {edir-2.36 → edir-2.37}/edir.py +50 -2
- {edir-2.36 → edir-2.37}/.gitignore +0 -0
- {edir-2.36 → edir-2.37}/edir.egg-info/dependency_links.txt +0 -0
- {edir-2.36 → edir-2.37}/edir.egg-info/entry_points.txt +0 -0
- {edir-2.36 → edir-2.37}/edir.egg-info/requires.txt +0 -0
- {edir-2.36 → edir-2.37}/edir.egg-info/top_level.txt +0 -0
- {edir-2.36 → edir-2.37}/justfile +0 -0
- {edir-2.36 → edir-2.37}/pyproject.toml +0 -0
- {edir-2.36 → edir-2.37}/setup.cfg +0 -0
{edir-2.36 → edir-2.37}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.37
|
|
4
4
|
Summary: Utility to rename, remove, and copy files/dirs using your editor
|
|
5
5
|
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -154,45 +154,49 @@ following ways:
|
|
|
154
154
|
19. `edir` filters out any duplicate paths you may inadvertently specify
|
|
155
155
|
on it's command line.
|
|
156
156
|
|
|
157
|
-
20. `edir`
|
|
157
|
+
20. `edir` provides an optional configuration file to set default `edir`
|
|
158
|
+
command line options. See [section below](#command-default-options).
|
|
159
|
+
|
|
160
|
+
21. `edir` always invokes a consistent duplicate renaming scheme. E.g. if
|
|
158
161
|
you rename `b`, `c`, `d` all to the same pre-existing name `a` then
|
|
159
|
-
`edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.
|
|
162
|
+
`edir` will rename `b` to `a~`, `c` to `a~1`, and `d` to `a~2`.
|
|
160
163
|
Depending on order of operations, `vidir` is not always consistent
|
|
161
|
-
about this, E.g. sometimes it creates a `a~1` with no `a
|
|
162
|
-
|
|
163
|
-
report/address?).
|
|
164
|
+
about this, E.g. sometimes it creates a `a~1` with no `a~`, or starts the
|
|
165
|
+
numbers with `a~2`. (these may be bugs in `vidir` that nobody has ever
|
|
166
|
+
bothered to report/address?).
|
|
167
|
+
|
|
168
|
+
22. Further to the previous item, `edir` allows you to change the format of the
|
|
169
|
+
name of copied files by specifying the `--copy-name-template` option. Refer
|
|
170
|
+
to the [section below](#custom-copied-file-template) for details.
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
23. `edir` creates the temporary editing file with a `.sh` suffix so
|
|
166
173
|
your EDITOR may syntax highlight the entries. Optionally, you can
|
|
167
174
|
change this default suffix.
|
|
168
175
|
|
|
169
|
-
|
|
176
|
+
24. `edir` provides an optional environment value to add custom options
|
|
170
177
|
to the invocation of your editor. See [section
|
|
171
178
|
below](#edir_editor-environment-variable).
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
command line options. See [section below](#command-default-options).
|
|
175
|
-
|
|
176
|
-
24. Contrary to what it's name implies, `vidir` actually respects your
|
|
180
|
+
25. Contrary to what it's name implies, `vidir` actually respects your
|
|
177
181
|
`$EDITOR` variable and runs your preferred editor like `edir` does
|
|
178
182
|
but `edir` has been given a generic name to make this more apparent.
|
|
179
183
|
If `$EDITOR` is not set then `edir` uses a default editor
|
|
180
184
|
appropriate to your system.
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
26. `vidir` returns status code 0 if all files successful, or 1 if any
|
|
183
187
|
error. `edir` returns 0 if all files successful, 1 if some had
|
|
184
188
|
error, or 2 if all had error.
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
27. `vidir` returns an error when attempting to rename across different
|
|
187
191
|
file systems, which `edir` allows.
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
28. By default, `edir` shows given paths relative to the current working
|
|
190
194
|
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
191
195
|
shows absolute paths (if they are given like that on the command line, e.g.
|
|
192
196
|
by an external tool). You can disable this relative path behavior in `edir`
|
|
193
197
|
if you want.
|
|
194
198
|
|
|
195
|
-
|
|
199
|
+
29. `edir` always ensures editor line numbers have the same width (e.g.
|
|
196
200
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
197
201
|
file names always line up justified. This facilitates block editing
|
|
198
202
|
of file names, e.g. using vim's [visual block
|
|
@@ -200,7 +204,7 @@ following ways:
|
|
|
200
204
|
do this so file names can be jagged wrt each other which makes block
|
|
201
205
|
editing awkward.
|
|
202
206
|
|
|
203
|
-
|
|
207
|
+
30. `edir` is very strict about the format of the lines you edit and
|
|
204
208
|
immediately exits with an error message (before changing anything)
|
|
205
209
|
if you format one of the lines incorrectly. All lines in the edited
|
|
206
210
|
list:
|
|
@@ -216,7 +220,7 @@ following ways:
|
|
|
216
220
|
line so an easy way to swap two file names is just to swap their
|
|
217
221
|
numbers.
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
31. `edir` always actions files consistently. The sequence of
|
|
220
224
|
operations applied is:
|
|
221
225
|
|
|
222
226
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -391,7 +395,8 @@ Type `edir -h` to view the usage summary:
|
|
|
391
395
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
392
396
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
393
397
|
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
394
|
-
[--suffix SUFFIX] [--
|
|
398
|
+
[--suffix SUFFIX] [--copy-name-template COPY_NAME_TEMPLATE]
|
|
399
|
+
[--no-relative] [-V] [--conf]
|
|
395
400
|
[args ...]
|
|
396
401
|
|
|
397
402
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -444,6 +449,10 @@ options:
|
|
|
444
449
|
group directories last (including when sorted)
|
|
445
450
|
-Z, --no-group-dirs negate the options to group directories
|
|
446
451
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
452
|
+
--copy-name-template COPY_NAME_TEMPLATE
|
|
453
|
+
specify copy file/path name template (%F=filename,
|
|
454
|
+
%Nd, %nd(no zero) where "d" is starting number),
|
|
455
|
+
default="%F~%n1"
|
|
447
456
|
--no-relative do not forcibly show paths relative to current working
|
|
448
457
|
directory
|
|
449
458
|
-V, --version show edir version
|
|
@@ -470,6 +479,46 @@ $ export EDIR_EDITOR="code -nw"
|
|
|
470
479
|
$ sudo -E edir /etc
|
|
471
480
|
```
|
|
472
481
|
|
|
482
|
+
## Custom Copied File Template
|
|
483
|
+
|
|
484
|
+
When you duplicate a line to copy a file or directory, `edir` ensures the new
|
|
485
|
+
copy has a unique name. By default it uses the same scheme as `vidir`, i.e, if
|
|
486
|
+
you rename `b`, `c`, `d` all to the same pre-existing name `a` then `edir` will
|
|
487
|
+
rename:
|
|
488
|
+
|
|
489
|
+
b -> a~
|
|
490
|
+
c -> a~1
|
|
491
|
+
d -> a~2
|
|
492
|
+
|
|
493
|
+
The format of the copied file name is defined by the `edir` default setting for
|
|
494
|
+
`--copy-name-template="%F~%n1"` where `%F` is the original file name, `%n1`
|
|
495
|
+
means suppress showing the first copy number (i.e. `~` instead of `~1` as in the
|
|
496
|
+
above example) and then start the remaining copies from 1.
|
|
497
|
+
|
|
498
|
+
You can also specify `%Nd` instead of `%nd` in the template to always show the
|
|
499
|
+
copy number even for the first copy, e.g. `--copy-name-template="%F~%N1"` would
|
|
500
|
+
instead produce:
|
|
501
|
+
|
|
502
|
+
b -> a~1
|
|
503
|
+
c -> a~2
|
|
504
|
+
d -> a~3
|
|
505
|
+
|
|
506
|
+
Some example other settings of `--copy-name-template` follow:
|
|
507
|
+
|
|
508
|
+
`--copy-name-template="%F-%N2"`:
|
|
509
|
+
|
|
510
|
+
b -> a-2
|
|
511
|
+
c -> a-3
|
|
512
|
+
d -> a-4
|
|
513
|
+
|
|
514
|
+
`--copy-name-template="%F-copy-%n2"`:
|
|
515
|
+
|
|
516
|
+
b -> a-copy
|
|
517
|
+
c -> a-copy-2
|
|
518
|
+
d -> a-copy-3
|
|
519
|
+
|
|
520
|
+
You are likely to want to set `--copy-name-template` as a [default option](#command-default-options).
|
|
521
|
+
|
|
473
522
|
## Embed in Ranger File Manager
|
|
474
523
|
|
|
475
524
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
@@ -140,45 +140,49 @@ following ways:
|
|
|
140
140
|
19. `edir` filters out any duplicate paths you may inadvertently specify
|
|
141
141
|
on it's command line.
|
|
142
142
|
|
|
143
|
-
20. `edir`
|
|
143
|
+
20. `edir` provides an optional configuration file to set default `edir`
|
|
144
|
+
command line options. See [section below](#command-default-options).
|
|
145
|
+
|
|
146
|
+
21. `edir` always invokes a consistent duplicate renaming scheme. E.g. if
|
|
144
147
|
you rename `b`, `c`, `d` all to the same pre-existing name `a` then
|
|
145
|
-
`edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.
|
|
148
|
+
`edir` will rename `b` to `a~`, `c` to `a~1`, and `d` to `a~2`.
|
|
146
149
|
Depending on order of operations, `vidir` is not always consistent
|
|
147
|
-
about this, E.g. sometimes it creates a `a~1` with no `a
|
|
148
|
-
|
|
149
|
-
report/address?).
|
|
150
|
+
about this, E.g. sometimes it creates a `a~1` with no `a~`, or starts the
|
|
151
|
+
numbers with `a~2`. (these may be bugs in `vidir` that nobody has ever
|
|
152
|
+
bothered to report/address?).
|
|
153
|
+
|
|
154
|
+
22. Further to the previous item, `edir` allows you to change the format of the
|
|
155
|
+
name of copied files by specifying the `--copy-name-template` option. Refer
|
|
156
|
+
to the [section below](#custom-copied-file-template) for details.
|
|
150
157
|
|
|
151
|
-
|
|
158
|
+
23. `edir` creates the temporary editing file with a `.sh` suffix so
|
|
152
159
|
your EDITOR may syntax highlight the entries. Optionally, you can
|
|
153
160
|
change this default suffix.
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
24. `edir` provides an optional environment value to add custom options
|
|
156
163
|
to the invocation of your editor. See [section
|
|
157
164
|
below](#edir_editor-environment-variable).
|
|
158
165
|
|
|
159
|
-
|
|
160
|
-
command line options. See [section below](#command-default-options).
|
|
161
|
-
|
|
162
|
-
24. Contrary to what it's name implies, `vidir` actually respects your
|
|
166
|
+
25. Contrary to what it's name implies, `vidir` actually respects your
|
|
163
167
|
`$EDITOR` variable and runs your preferred editor like `edir` does
|
|
164
168
|
but `edir` has been given a generic name to make this more apparent.
|
|
165
169
|
If `$EDITOR` is not set then `edir` uses a default editor
|
|
166
170
|
appropriate to your system.
|
|
167
171
|
|
|
168
|
-
|
|
172
|
+
26. `vidir` returns status code 0 if all files successful, or 1 if any
|
|
169
173
|
error. `edir` returns 0 if all files successful, 1 if some had
|
|
170
174
|
error, or 2 if all had error.
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
27. `vidir` returns an error when attempting to rename across different
|
|
173
177
|
file systems, which `edir` allows.
|
|
174
178
|
|
|
175
|
-
|
|
179
|
+
28. By default, `edir` shows given paths relative to the current working
|
|
176
180
|
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
177
181
|
shows absolute paths (if they are given like that on the command line, e.g.
|
|
178
182
|
by an external tool). You can disable this relative path behavior in `edir`
|
|
179
183
|
if you want.
|
|
180
184
|
|
|
181
|
-
|
|
185
|
+
29. `edir` always ensures editor line numbers have the same width (e.g.
|
|
182
186
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
183
187
|
file names always line up justified. This facilitates block editing
|
|
184
188
|
of file names, e.g. using vim's [visual block
|
|
@@ -186,7 +190,7 @@ following ways:
|
|
|
186
190
|
do this so file names can be jagged wrt each other which makes block
|
|
187
191
|
editing awkward.
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
30. `edir` is very strict about the format of the lines you edit and
|
|
190
194
|
immediately exits with an error message (before changing anything)
|
|
191
195
|
if you format one of the lines incorrectly. All lines in the edited
|
|
192
196
|
list:
|
|
@@ -202,7 +206,7 @@ following ways:
|
|
|
202
206
|
line so an easy way to swap two file names is just to swap their
|
|
203
207
|
numbers.
|
|
204
208
|
|
|
205
|
-
|
|
209
|
+
31. `edir` always actions files consistently. The sequence of
|
|
206
210
|
operations applied is:
|
|
207
211
|
|
|
208
212
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -377,7 +381,8 @@ Type `edir -h` to view the usage summary:
|
|
|
377
381
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
378
382
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
379
383
|
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
380
|
-
[--suffix SUFFIX] [--
|
|
384
|
+
[--suffix SUFFIX] [--copy-name-template COPY_NAME_TEMPLATE]
|
|
385
|
+
[--no-relative] [-V] [--conf]
|
|
381
386
|
[args ...]
|
|
382
387
|
|
|
383
388
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -430,6 +435,10 @@ options:
|
|
|
430
435
|
group directories last (including when sorted)
|
|
431
436
|
-Z, --no-group-dirs negate the options to group directories
|
|
432
437
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
438
|
+
--copy-name-template COPY_NAME_TEMPLATE
|
|
439
|
+
specify copy file/path name template (%F=filename,
|
|
440
|
+
%Nd, %nd(no zero) where "d" is starting number),
|
|
441
|
+
default="%F~%n1"
|
|
433
442
|
--no-relative do not forcibly show paths relative to current working
|
|
434
443
|
directory
|
|
435
444
|
-V, --version show edir version
|
|
@@ -456,6 +465,46 @@ $ export EDIR_EDITOR="code -nw"
|
|
|
456
465
|
$ sudo -E edir /etc
|
|
457
466
|
```
|
|
458
467
|
|
|
468
|
+
## Custom Copied File Template
|
|
469
|
+
|
|
470
|
+
When you duplicate a line to copy a file or directory, `edir` ensures the new
|
|
471
|
+
copy has a unique name. By default it uses the same scheme as `vidir`, i.e, if
|
|
472
|
+
you rename `b`, `c`, `d` all to the same pre-existing name `a` then `edir` will
|
|
473
|
+
rename:
|
|
474
|
+
|
|
475
|
+
b -> a~
|
|
476
|
+
c -> a~1
|
|
477
|
+
d -> a~2
|
|
478
|
+
|
|
479
|
+
The format of the copied file name is defined by the `edir` default setting for
|
|
480
|
+
`--copy-name-template="%F~%n1"` where `%F` is the original file name, `%n1`
|
|
481
|
+
means suppress showing the first copy number (i.e. `~` instead of `~1` as in the
|
|
482
|
+
above example) and then start the remaining copies from 1.
|
|
483
|
+
|
|
484
|
+
You can also specify `%Nd` instead of `%nd` in the template to always show the
|
|
485
|
+
copy number even for the first copy, e.g. `--copy-name-template="%F~%N1"` would
|
|
486
|
+
instead produce:
|
|
487
|
+
|
|
488
|
+
b -> a~1
|
|
489
|
+
c -> a~2
|
|
490
|
+
d -> a~3
|
|
491
|
+
|
|
492
|
+
Some example other settings of `--copy-name-template` follow:
|
|
493
|
+
|
|
494
|
+
`--copy-name-template="%F-%N2"`:
|
|
495
|
+
|
|
496
|
+
b -> a-2
|
|
497
|
+
c -> a-3
|
|
498
|
+
d -> a-4
|
|
499
|
+
|
|
500
|
+
`--copy-name-template="%F-copy-%n2"`:
|
|
501
|
+
|
|
502
|
+
b -> a-copy
|
|
503
|
+
c -> a-copy-2
|
|
504
|
+
d -> a-copy-3
|
|
505
|
+
|
|
506
|
+
You are likely to want to set `--copy-name-template` as a [default option](#command-default-options).
|
|
507
|
+
|
|
459
508
|
## Embed in Ranger File Manager
|
|
460
509
|
|
|
461
510
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.37
|
|
4
4
|
Summary: Utility to rename, remove, and copy files/dirs using your editor
|
|
5
5
|
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -154,45 +154,49 @@ following ways:
|
|
|
154
154
|
19. `edir` filters out any duplicate paths you may inadvertently specify
|
|
155
155
|
on it's command line.
|
|
156
156
|
|
|
157
|
-
20. `edir`
|
|
157
|
+
20. `edir` provides an optional configuration file to set default `edir`
|
|
158
|
+
command line options. See [section below](#command-default-options).
|
|
159
|
+
|
|
160
|
+
21. `edir` always invokes a consistent duplicate renaming scheme. E.g. if
|
|
158
161
|
you rename `b`, `c`, `d` all to the same pre-existing name `a` then
|
|
159
|
-
`edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.
|
|
162
|
+
`edir` will rename `b` to `a~`, `c` to `a~1`, and `d` to `a~2`.
|
|
160
163
|
Depending on order of operations, `vidir` is not always consistent
|
|
161
|
-
about this, E.g. sometimes it creates a `a~1` with no `a
|
|
162
|
-
|
|
163
|
-
report/address?).
|
|
164
|
+
about this, E.g. sometimes it creates a `a~1` with no `a~`, or starts the
|
|
165
|
+
numbers with `a~2`. (these may be bugs in `vidir` that nobody has ever
|
|
166
|
+
bothered to report/address?).
|
|
167
|
+
|
|
168
|
+
22. Further to the previous item, `edir` allows you to change the format of the
|
|
169
|
+
name of copied files by specifying the `--copy-name-template` option. Refer
|
|
170
|
+
to the [section below](#custom-copied-file-template) for details.
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
23. `edir` creates the temporary editing file with a `.sh` suffix so
|
|
166
173
|
your EDITOR may syntax highlight the entries. Optionally, you can
|
|
167
174
|
change this default suffix.
|
|
168
175
|
|
|
169
|
-
|
|
176
|
+
24. `edir` provides an optional environment value to add custom options
|
|
170
177
|
to the invocation of your editor. See [section
|
|
171
178
|
below](#edir_editor-environment-variable).
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
command line options. See [section below](#command-default-options).
|
|
175
|
-
|
|
176
|
-
24. Contrary to what it's name implies, `vidir` actually respects your
|
|
180
|
+
25. Contrary to what it's name implies, `vidir` actually respects your
|
|
177
181
|
`$EDITOR` variable and runs your preferred editor like `edir` does
|
|
178
182
|
but `edir` has been given a generic name to make this more apparent.
|
|
179
183
|
If `$EDITOR` is not set then `edir` uses a default editor
|
|
180
184
|
appropriate to your system.
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
26. `vidir` returns status code 0 if all files successful, or 1 if any
|
|
183
187
|
error. `edir` returns 0 if all files successful, 1 if some had
|
|
184
188
|
error, or 2 if all had error.
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
27. `vidir` returns an error when attempting to rename across different
|
|
187
191
|
file systems, which `edir` allows.
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
28. By default, `edir` shows given paths relative to the current working
|
|
190
194
|
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
191
195
|
shows absolute paths (if they are given like that on the command line, e.g.
|
|
192
196
|
by an external tool). You can disable this relative path behavior in `edir`
|
|
193
197
|
if you want.
|
|
194
198
|
|
|
195
|
-
|
|
199
|
+
29. `edir` always ensures editor line numbers have the same width (e.g.
|
|
196
200
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
197
201
|
file names always line up justified. This facilitates block editing
|
|
198
202
|
of file names, e.g. using vim's [visual block
|
|
@@ -200,7 +204,7 @@ following ways:
|
|
|
200
204
|
do this so file names can be jagged wrt each other which makes block
|
|
201
205
|
editing awkward.
|
|
202
206
|
|
|
203
|
-
|
|
207
|
+
30. `edir` is very strict about the format of the lines you edit and
|
|
204
208
|
immediately exits with an error message (before changing anything)
|
|
205
209
|
if you format one of the lines incorrectly. All lines in the edited
|
|
206
210
|
list:
|
|
@@ -216,7 +220,7 @@ following ways:
|
|
|
216
220
|
line so an easy way to swap two file names is just to swap their
|
|
217
221
|
numbers.
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
31. `edir` always actions files consistently. The sequence of
|
|
220
224
|
operations applied is:
|
|
221
225
|
|
|
222
226
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -391,7 +395,8 @@ Type `edir -h` to view the usage summary:
|
|
|
391
395
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
392
396
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
393
397
|
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
394
|
-
[--suffix SUFFIX] [--
|
|
398
|
+
[--suffix SUFFIX] [--copy-name-template COPY_NAME_TEMPLATE]
|
|
399
|
+
[--no-relative] [-V] [--conf]
|
|
395
400
|
[args ...]
|
|
396
401
|
|
|
397
402
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -444,6 +449,10 @@ options:
|
|
|
444
449
|
group directories last (including when sorted)
|
|
445
450
|
-Z, --no-group-dirs negate the options to group directories
|
|
446
451
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
452
|
+
--copy-name-template COPY_NAME_TEMPLATE
|
|
453
|
+
specify copy file/path name template (%F=filename,
|
|
454
|
+
%Nd, %nd(no zero) where "d" is starting number),
|
|
455
|
+
default="%F~%n1"
|
|
447
456
|
--no-relative do not forcibly show paths relative to current working
|
|
448
457
|
directory
|
|
449
458
|
-V, --version show edir version
|
|
@@ -470,6 +479,46 @@ $ export EDIR_EDITOR="code -nw"
|
|
|
470
479
|
$ sudo -E edir /etc
|
|
471
480
|
```
|
|
472
481
|
|
|
482
|
+
## Custom Copied File Template
|
|
483
|
+
|
|
484
|
+
When you duplicate a line to copy a file or directory, `edir` ensures the new
|
|
485
|
+
copy has a unique name. By default it uses the same scheme as `vidir`, i.e, if
|
|
486
|
+
you rename `b`, `c`, `d` all to the same pre-existing name `a` then `edir` will
|
|
487
|
+
rename:
|
|
488
|
+
|
|
489
|
+
b -> a~
|
|
490
|
+
c -> a~1
|
|
491
|
+
d -> a~2
|
|
492
|
+
|
|
493
|
+
The format of the copied file name is defined by the `edir` default setting for
|
|
494
|
+
`--copy-name-template="%F~%n1"` where `%F` is the original file name, `%n1`
|
|
495
|
+
means suppress showing the first copy number (i.e. `~` instead of `~1` as in the
|
|
496
|
+
above example) and then start the remaining copies from 1.
|
|
497
|
+
|
|
498
|
+
You can also specify `%Nd` instead of `%nd` in the template to always show the
|
|
499
|
+
copy number even for the first copy, e.g. `--copy-name-template="%F~%N1"` would
|
|
500
|
+
instead produce:
|
|
501
|
+
|
|
502
|
+
b -> a~1
|
|
503
|
+
c -> a~2
|
|
504
|
+
d -> a~3
|
|
505
|
+
|
|
506
|
+
Some example other settings of `--copy-name-template` follow:
|
|
507
|
+
|
|
508
|
+
`--copy-name-template="%F-%N2"`:
|
|
509
|
+
|
|
510
|
+
b -> a-2
|
|
511
|
+
c -> a-3
|
|
512
|
+
d -> a-4
|
|
513
|
+
|
|
514
|
+
`--copy-name-template="%F-copy-%n2"`:
|
|
515
|
+
|
|
516
|
+
b -> a-copy
|
|
517
|
+
c -> a-copy-2
|
|
518
|
+
d -> a-copy-3
|
|
519
|
+
|
|
520
|
+
You are likely to want to set `--copy-name-template` as a [default option](#command-default-options).
|
|
521
|
+
|
|
473
522
|
## Embed in Ranger File Manager
|
|
474
523
|
|
|
475
524
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
{edir-2.36 → edir-2.37}/edir.py
RENAMED
|
@@ -12,6 +12,7 @@ from __future__ import annotations
|
|
|
12
12
|
|
|
13
13
|
import itertools
|
|
14
14
|
import os
|
|
15
|
+
import re
|
|
15
16
|
import shlex
|
|
16
17
|
import shutil
|
|
17
18
|
import subprocess
|
|
@@ -19,6 +20,7 @@ import sys
|
|
|
19
20
|
import tempfile
|
|
20
21
|
from collections.abc import Callable, Iterable, Sequence
|
|
21
22
|
from pathlib import Path
|
|
23
|
+
from typing import NoReturn
|
|
22
24
|
|
|
23
25
|
import argparse_from_file as argparse
|
|
24
26
|
|
|
@@ -240,6 +242,46 @@ def removeprefix(s: str, prefix: str) -> str:
|
|
|
240
242
|
return s[len(prefix) :] if s.startswith(prefix) else s
|
|
241
243
|
|
|
242
244
|
|
|
245
|
+
class CopyNameTemplate:
|
|
246
|
+
"Class to manage copy file/path name template"
|
|
247
|
+
|
|
248
|
+
DEFAULT = '%F~%n1'
|
|
249
|
+
HELP = (
|
|
250
|
+
'specify copy file/path name template (%%F=filename, %%Nd, %%nd(no zero) '
|
|
251
|
+
'where "d" is starting number), default="%(default)s"'
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
def __init__(self, template: str) -> None:
|
|
255
|
+
"Create a template for copy file/path names from given name"
|
|
256
|
+
|
|
257
|
+
def _exit(msg: str) -> NoReturn:
|
|
258
|
+
sys.exit(f'ERROR: --copy-name-template "{template}" {msg}')
|
|
259
|
+
|
|
260
|
+
if '%F' not in template:
|
|
261
|
+
_exit('must contain "%F" for filename')
|
|
262
|
+
|
|
263
|
+
m = re.search(r'%[nN]\d+', template)
|
|
264
|
+
if not m:
|
|
265
|
+
_exit('must contain "%nd" or "%Nd" for count')
|
|
266
|
+
|
|
267
|
+
if len(m.groups()) > 1:
|
|
268
|
+
_exit('can contain only one "%nd" or "%Nd" specifier for count')
|
|
269
|
+
|
|
270
|
+
numstr = m.group(0)
|
|
271
|
+
self.count_start = int(numstr[2:])
|
|
272
|
+
self.include_first = numstr[1] == 'N'
|
|
273
|
+
|
|
274
|
+
if not self.include_first:
|
|
275
|
+
self.count_start -= 1
|
|
276
|
+
|
|
277
|
+
self.template = template.replace('%F', '{name}').replace(numstr, '{num}')
|
|
278
|
+
|
|
279
|
+
def create(self, name: str, num: int) -> str:
|
|
280
|
+
"Return a copy name from the template for given name and count"
|
|
281
|
+
numstr = str(num + self.count_start) if num > 0 or self.include_first else ''
|
|
282
|
+
return self.template.format(name=name, num=numstr)
|
|
283
|
+
|
|
284
|
+
|
|
243
285
|
class Fpath:
|
|
244
286
|
"Class to manage each instance of a file/dir"
|
|
245
287
|
|
|
@@ -278,7 +320,7 @@ class Fpath:
|
|
|
278
320
|
for c in itertools.count():
|
|
279
321
|
if not path.is_symlink() and not path.exists():
|
|
280
322
|
break
|
|
281
|
-
path = path.with_name(name
|
|
323
|
+
path = path.with_name(args._copy_name(name, c))
|
|
282
324
|
|
|
283
325
|
return path
|
|
284
326
|
|
|
@@ -769,6 +811,11 @@ def main() -> int:
|
|
|
769
811
|
default=SUFFIX,
|
|
770
812
|
help='specify suffix for temp editor file, default="%(default)s"',
|
|
771
813
|
)
|
|
814
|
+
opt.add_argument(
|
|
815
|
+
'--copy-name-template',
|
|
816
|
+
default=CopyNameTemplate.DEFAULT,
|
|
817
|
+
help=CopyNameTemplate.HELP,
|
|
818
|
+
)
|
|
772
819
|
opt.add_argument(
|
|
773
820
|
'--no-relative',
|
|
774
821
|
action='store_true',
|
|
@@ -801,7 +848,6 @@ def main() -> int:
|
|
|
801
848
|
# Edit the configuration file and exit
|
|
802
849
|
if not (conf_file := opt.from_file_path):
|
|
803
850
|
opt.error('No configuration file path determined.')
|
|
804
|
-
return 1
|
|
805
851
|
|
|
806
852
|
edit_file_conf(conf_file)
|
|
807
853
|
return 0
|
|
@@ -812,6 +858,8 @@ def main() -> int:
|
|
|
812
858
|
|
|
813
859
|
args.trash_program = args.trash_program.split()
|
|
814
860
|
|
|
861
|
+
args._copy_name = CopyNameTemplate(args.copy_name_template).create
|
|
862
|
+
|
|
815
863
|
# Check if we are in a git repo
|
|
816
864
|
if args.git != 0:
|
|
817
865
|
out, giterr = run(('git', 'ls-files'))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{edir-2.36 → edir-2.37}/justfile
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|