mvb 0.0.1 → 0.0.3
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.
- checksums.yaml +4 -4
- data/exe/mvb +82 -26
- data/lib/mvb/version.rb +1 -1
- data/lib/mvb.rb +1 -1
- metadata +12 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f52946fe658cc5bcd3a37a90dbc0fad9c334c25dad48dab750f1bd084a6438cd
|
|
4
|
+
data.tar.gz: 27740c082628cedc8e9d5bf40a8519b1172527a48a5e5dc768b494261668aa0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 905eea5055c13151a502cc6f3d6984bd23e4a82ebd3ff49f6129fa3729126d33cd7642c8d7d4a3dc005d723c66d0c62ca05a22852437a0462b2a3d91a50b00f1
|
|
7
|
+
data.tar.gz: 4f88e22c25b5d1cc5081b106abde06eef3fa0e5ef52f98a19e27a6d5e13e4280d111028fbc631e116fa848611acd74480d59a3e6886cec81c3ade78b96a20914
|
data/exe/mvb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
# Tienes una nota en Joplin. Léela.
|
|
3
2
|
|
|
4
3
|
require 'optparse'
|
|
5
4
|
require_relative '../lib/mvb'
|
|
@@ -11,32 +10,85 @@ pattern = nil
|
|
|
11
10
|
force_rename = false
|
|
12
11
|
steps = 1
|
|
13
12
|
|
|
14
|
-
banner =
|
|
15
|
-
Usage:
|
|
16
|
-
mvb [-s,--search] "PATTERN" [-r,--replacement] ["STRING"] [-f,--force]
|
|
13
|
+
banner = <<EOM
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
COMMAND USAGE:
|
|
16
|
+
mvb [-s,--search] "REGEX_PATTERN" [-r,--replacement] ["REPLACEMENT"] [-f,--force] [-i,--step N] [-h, --help]
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
the
|
|
18
|
+
You can enter the search and replacement arguments by tag or by position. Tag options get precedence over positions.
|
|
19
|
+
In positional options, first argument corresponds to the search pattern, and second argument, to the replacement.
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
and second column their replacement counterpart. This will be a dry-run, though; no rename
|
|
27
|
-
will be executed
|
|
21
|
+
COMMAND USAGE WITH POSITIONAL ARGUMENTS:
|
|
22
|
+
mvb "REGEX_PATTERN" ["REPLACEMENT"] [tag options...]
|
|
28
23
|
|
|
29
|
-
|
|
24
|
+
The only required argument is the search pattern. If replacement is not given,
|
|
25
|
+
the output is a list of the matched files.
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
If both options are given (search and replacement), the output will consist of two columns:
|
|
28
|
+
first column lists the current filenames matched by the search pattern,
|
|
29
|
+
and second column their replacement counterpart.
|
|
30
|
+
If -f tag is not given, this list will be a dry-run; no rename will be executed.
|
|
31
|
+
|
|
32
|
+
To execute the rename, add the --force (or -f) tag option.
|
|
33
|
+
|
|
34
|
+
The search pattern can be a normal string or a regex pattern. The syntax of the regex partten is the one
|
|
35
|
+
used by Ruby. Which follows the PCRE convension; it is very similar VSCode's.
|
|
36
|
+
|
|
37
|
+
In replacement string, you can access to captured groups via "\\n" syntax, where "n" is the
|
|
38
|
+
group number; e.g. "\\1", "\\2", "\\3", etc.
|
|
39
|
+
|
|
40
|
+
IMPORTANT:
|
|
41
|
+
This program is designed to rename files located at root folder.
|
|
42
|
+
So, you need first to change directory to the location of the files in order to use mvb.
|
|
43
|
+
|
|
44
|
+
If the search or replacement contain characters like backslashes, asterisks, parentheses or
|
|
45
|
+
brackets, you must enclose these fields in double quotes in order to avoid conflicts
|
|
46
|
+
with the wildcards of the shell. Otherwise, you will experience unexpected results.
|
|
47
|
+
On the other hand, if these fields are composed by letters and other typical chars, you can omit
|
|
48
|
+
the double quotes. To stay on the safe side, however, it is recommended to use double-quotes always.
|
|
34
49
|
|
|
35
50
|
SEQUENTIAL NUMBERING:
|
|
36
|
-
|
|
37
|
-
with an integer
|
|
38
|
-
the output will consist of: image-1, image-2, image-3, etc. until reached the last replacement item.
|
|
39
|
-
You can use the option `-i` to set the
|
|
51
|
+
In replacement string, you can introduce sequential numbering by using "#" as placeholder along
|
|
52
|
+
with an integer used as starting point. For example, if you use "image-#1" as replacement,
|
|
53
|
+
the output will consist of: image-1, image-2, image-3, etc. until reached the last replacement item.
|
|
54
|
+
You can use the option `-i` to set the step of increment.
|
|
55
|
+
|
|
56
|
+
EXAMPLES OF USAGE:
|
|
57
|
+
Given this batch of files on root folder: book1.txt, book2.txt, book3.txt, book4.txt.
|
|
58
|
+
Consider the following examples of usage.
|
|
59
|
+
|
|
60
|
+
EXAMPLE 1 - List of the matched files
|
|
61
|
+
|
|
62
|
+
$ mvb book
|
|
63
|
+
book1.txt
|
|
64
|
+
book2.txt
|
|
65
|
+
book3.txt
|
|
66
|
+
book4.txt
|
|
67
|
+
|
|
68
|
+
EXAMPLE 2 - Dry-run of replacement
|
|
69
|
+
|
|
70
|
+
$ mvb book libro
|
|
71
|
+
book1.txt --> libro1.txt
|
|
72
|
+
book2.txt --> libro2.txt
|
|
73
|
+
book3.txt --> libro3.txt
|
|
74
|
+
book4.txt --> libro4.txt
|
|
75
|
+
|
|
76
|
+
EXAMPLE 3 - Dry-run of replacement, with sequential numbering
|
|
77
|
+
|
|
78
|
+
$ mvb "book\\d" "libro#3"
|
|
79
|
+
book1.txt --> libro3.txt
|
|
80
|
+
book2.txt --> libro4.txt
|
|
81
|
+
book3.txt --> libro5.txt
|
|
82
|
+
book4.txt --> libro6.txt
|
|
83
|
+
|
|
84
|
+
EXAMPLE 4 - Dry-run of replacement, with sequential numbering and increments of 2
|
|
85
|
+
|
|
86
|
+
$ mvb "book\d" "libro#3" -i 2
|
|
87
|
+
book1.txt --> libro3.txt
|
|
88
|
+
book2.txt --> libro5.txt
|
|
89
|
+
book3.txt --> libro7.txt
|
|
90
|
+
book4.txt --> libro9.txt
|
|
91
|
+
|
|
40
92
|
|
|
41
93
|
EOM
|
|
42
94
|
|
|
@@ -44,28 +96,32 @@ opt_parser = OptionParser.new do |opts|
|
|
|
44
96
|
|
|
45
97
|
opts.banner = banner
|
|
46
98
|
|
|
47
|
-
opts.on("-s", "--search
|
|
48
|
-
just list the matched files. Argument required, option tag is not required.") do |argument|
|
|
99
|
+
opts.on("-s", "--search REGEX_PATTERN", "Search for files that match with PATTERN. If no replacement is given, just list the matched files. Required. Tag not required") do |argument|
|
|
49
100
|
search = argument
|
|
50
101
|
end
|
|
51
102
|
|
|
52
|
-
opts.on("-r", "--replacement
|
|
103
|
+
opts.on("-r", "--replacement STRING", "Replace the matched files with given STRING. Optional. Tag is not required") do |argument|
|
|
53
104
|
replacement = argument
|
|
54
105
|
end
|
|
55
106
|
|
|
56
|
-
opts.on("-f", "--force", "Execute
|
|
107
|
+
opts.on("-f", "--force", "Execute rename") do
|
|
57
108
|
force_rename = true
|
|
58
109
|
end
|
|
59
110
|
|
|
60
|
-
opts.on("-i
|
|
111
|
+
opts.on("-i STEP", "--step=STEP", "Step of increment on sequential numbering" ) do |argument|
|
|
61
112
|
steps = argument.to_i if argument.to_i != 0
|
|
62
113
|
end
|
|
63
114
|
|
|
64
|
-
opts.on("-h", "--help", "Show this help message
|
|
115
|
+
opts.on("-h", "--help", "Show this help message") do
|
|
65
116
|
puts opts
|
|
66
117
|
exit
|
|
67
118
|
end
|
|
68
119
|
|
|
120
|
+
opts.on("-v", "--version", "Show gem version") do
|
|
121
|
+
puts "mvb version: #{Mvb::VERSION}"
|
|
122
|
+
exit
|
|
123
|
+
end
|
|
124
|
+
|
|
69
125
|
end
|
|
70
126
|
|
|
71
127
|
# Parse the options and store remaining arguments as positional
|
data/lib/mvb/version.rb
CHANGED
data/lib/mvb.rb
CHANGED
metadata
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mvb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Manuel Fuenmayor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-10-
|
|
11
|
+
date: 2024-10-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
13
|
+
description: |
|
|
14
|
+
This is a simple-to-use command-line gem to rename batch of files (or folders) using regex patterns. Sequential numbering feature is also added to re-define (or establish) numbered files.
|
|
15
|
+
|
|
16
|
+
Supported regex follows PCRE convention which is very similar to the one used by VSCode.
|
|
17
|
+
|
|
18
|
+
At this stage, this program is designed to rename files located at root folder. Therefore, you would need first to change directory to the location of the files to use mvb.
|
|
19
|
+
|
|
20
|
+
For full documentation, use "mvb -h".
|
|
14
21
|
email: manuel.fuenmayor98@gmail.com
|
|
15
22
|
executables:
|
|
16
23
|
- mvb
|
|
@@ -32,7 +39,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
32
39
|
requirements:
|
|
33
40
|
- - ">="
|
|
34
41
|
- !ruby/object:Gem::Version
|
|
35
|
-
version: '
|
|
42
|
+
version: '2.5'
|
|
36
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
44
|
requirements:
|
|
38
45
|
- - ">="
|
|
@@ -42,5 +49,5 @@ requirements: []
|
|
|
42
49
|
rubygems_version: 3.5.20
|
|
43
50
|
signing_key:
|
|
44
51
|
specification_version: 4
|
|
45
|
-
summary: A
|
|
52
|
+
summary: A gem to rename batch of files using regex, with sequential numbering capabilities.
|
|
46
53
|
test_files: []
|