feat: add counters to bulk rename function #2525
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request introduces counter-based bulk renaming to Yazi, enabling users to specify incrementing placeholders across multiple lines. Each line can include zero or more placeholders of the form:
where:
<COUNT_TYPE>
: A single character indicating the counter type:N
,n
,D
,d
→ Numeric digits.A
→ Uppercase ANSI letters.a
→ Lowercase ANSI letters.R
→ Uppercase Roman numerals.r
→ Lowercase Roman numerals.C
→ Uppercase Cyrillic letters.c
→ Lowercase Cyrillic letters.<START_VALUE>
(optional): Initial value, either as a number (e.g.,1
,2
, etc.) or a value corresponding to the counter type:A
,B
,AA
(ANSI uppercase)a
,b
,aa
(ANSI lowercase)I
,II
,III
(Roman uppercase)i
,ii
,iii
(Roman lowercase)А
,Б
,АБ
(Cyrillic uppercase)а
,б
,аб
(Cyrillic lowercase)_
for unspecified.<COUNT_STEP>
(optional): Step size, integer (e.g.,2
) or_
for unspecified.<COUNT_WIDTH>
(optional): Minimum width with zero-padding. Integer (e.g.,3
) or_
for unspecified.Optional parameters (
<START_VALUE>
,<STEP>
,<WIDTH>
) can be set or left as_
to take defaults. For instance,%{n,_,2,3}
starts at the default value 1, increments by 2, and has a minimum width of 3. They also can be omitted, i.e. not written at all. For example, you can write%{N}
,%{N, 1}
Optional parameters must be specified sequentially:
<START_VALUE>
is required if<COUNT_STEP>
or<COUNT_WIDTH>
are used, either explicitly (e.g.,1
) or with_
. Omitting earlier parameters with commas (e.g.,%{N,,2}
or%{N,,,4}
) is invalid. User should write%{N,_,2}
or%{N,_,_,4}
instead.Escaping: To insert a literal
%{
in filenames (in linux for example), user could escape it by writing%%{
. For example,file_%%{name}.txt
will becomefile_%{name}.txt
.Constraints & Error Handling:
To avoid adding extra dependencies, the parser is custom-written. While parsing performance could theoretically be improved using Rayon parallelization, I think that typical usage scenarios likely won’t require such optimization.
default.mp4