mvb 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/exe/mvb +68 -26
  3. data/lib/mvb/version.rb +1 -1
  4. data/lib/mvb.rb +1 -1
  5. metadata +21 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9a9dd9a37c9202b5016f54508d32d876b2baa95ab86f90355d9763427a6e79f
4
- data.tar.gz: f40d7182c62000bcbd455d7e3a7c51d47ecc79ad17b1767ed20d88da1fd4c1a1
3
+ metadata.gz: 47d91800a8898d0131c45a145abec0ee88ef41a83447fff0f54db36362e43d90
4
+ data.tar.gz: 0fa6cf9bc0dc3c5b3a8789201bda72220d71a14619428da96228ff9cc6e6eb85
5
5
  SHA512:
6
- metadata.gz: ac6bcf8e1d406b49e1a40b72fbaa6e1f1c3eed1e539b1a5e58b2e06d848e06f651ee1f077c4ee7445add1e884bbf8cc328920160fda21ee027a6c14992ccf472
7
- data.tar.gz: 35388f1ba151d170dda9e4aa18f4bce064f02519a9c913f42a3411c932397c64d6c6ae66fc5eddeccf4da1a411f34eeea5f3c54dbfa70e7f6f8e04242bd1d87d
6
+ metadata.gz: feaa2cd714d2ad154af049f5ca8d57503693126f20be2c7acfc4ecea0023ee729ae4f985f47b9ed0697ae8743b6744641e2d8a1bc2924d80b49f8c85a877ad5f
7
+ data.tar.gz: 938b581a46d7f5193e34261b1a75f2b1bb4a2190eccafb663a4d81ee14e17aeec9c3ade65e91330901a4502a82b83928d5a18add88b4134ab3be1ec79c5ea37a
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,76 @@ pattern = nil
11
10
  force_rename = false
12
11
  steps = 1
13
12
 
14
- banner = <<~EOM
15
- Usage:
16
- mvb [-s,--search] "PATTERN" [-r,--replacement] ["STRING"] [-f,--force]
13
+ banner = <<EOM
17
14
 
18
- You can enter the arguments by option tags or by position. Tag options get precedence over positions.
19
- In positional options, first argument corresponds to the search pattern, and second, the replacement.
15
+ COMMAND USAGE:
16
+ mvb [-s,--search] "REGEX_PATTERN" [-r,--replacement] ["REPLACEMENT"] [-f,--force] [-i,--step N] [-h, --help]
20
17
 
21
- The only required argument is the search pattern. If replacement is not given,
22
- the output is a list of the matched files.
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
- If both options are given (search and replacement), the output will consists
25
- of two columns: first column lists the current filenames matched by the search patterns,
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
- To execute the rename, add the --force (or -f) option.
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
- IMPORTANT: if you are going to use regex as pattern, it is strongly recommended
32
- to enclose it in double quotes in order to avoid conflicts between the regex
33
- special characters and the wildcards of the shell.
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
- On replacement string, you can introduce sequential numbering by using a "#" as placeholder along
37
- with an integer which will be the starting point. For example, if you use "image-#1" as replacement,
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 steps of increments.
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 and 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
40
83
 
41
84
  EOM
42
85
 
@@ -44,24 +87,23 @@ opt_parser = OptionParser.new do |opts|
44
87
 
45
88
  opts.banner = banner
46
89
 
47
- opts.on("-s", "--search PATTERN", "Search for files that match with PATTERN. If no replace PATTERN is given,
48
- just list the matched files. Argument required, option tag is not required.") do |argument|
90
+ 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
91
  search = argument
50
92
  end
51
93
 
52
- opts.on("-r", "--replacement PATTERN", "Replace the matched files with given PATTERN. Optional.") do |argument|
94
+ opts.on("-r", "--replacement STRING", "Replace the matched files with given STRING. Optional. Tag is not required") do |argument|
53
95
  replacement = argument
54
96
  end
55
97
 
56
- opts.on("-f", "--force", "Execute renaming") do
98
+ opts.on("-f", "--force", "Execute rename") do
57
99
  force_rename = true
58
100
  end
59
101
 
60
- opts.on("-i STEPS", "--steps=STEPS", "Steps of increment on sequential numbering." ) do |argument|
102
+ opts.on("-i STEP", "--step=STEP", "Step of increment on sequential numbering" ) do |argument|
61
103
  steps = argument.to_i if argument.to_i != 0
62
104
  end
63
105
 
64
- opts.on("-h", "--help", "Show this help message.") do
106
+ opts.on("-h", "--help", "Show this help message") do
65
107
  puts opts
66
108
  exit
67
109
  end
data/lib/mvb/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Mvb
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
data/lib/mvb.rb CHANGED
@@ -104,7 +104,7 @@ module Mvb
104
104
  if force_rename
105
105
  puts "\nFiles renamed!"
106
106
  else
107
- puts "\nThis is a dry-run. No file has been renamed."
107
+ puts "\nThis is a dry-run. No file has been renamed.\nAdd -f to execute rename."
108
108
  end
109
109
  end
110
110
 
metadata CHANGED
@@ -1,16 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mvb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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 00:00:00.000000000 Z
11
+ date: 2024-10-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: A gem to rename batch of files, with sequential numbering feature
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 stablish) numbered files.
15
+
16
+ Structure of the command:
17
+ mvb [-s,--search] "REGEX_PATTERN" [-r,--replacement] ["REPLACEMENT"] [-f,--force] [-i,--step N] [-h, --help]
18
+
19
+ The "search" and "replacement" arguments can be entered based on position (i.e. no need for a tag).
20
+
21
+ Structure using positional arguments:
22
+ mvb "REGEX_PATTERN" ["REPLACEMENT"] [tag options...]
23
+
24
+ Supported regex syntax follows PCRE convention, which is very similar to the one used by VS Code.
25
+
26
+ 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.
27
+
28
+ For more information, use "mvb -h".
14
29
  email: manuel.fuenmayor98@gmail.com
15
30
  executables:
16
31
  - mvb
@@ -32,7 +47,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
32
47
  requirements:
33
48
  - - ">="
34
49
  - !ruby/object:Gem::Version
35
- version: '0'
50
+ version: '2.5'
36
51
  required_rubygems_version: !ruby/object:Gem::Requirement
37
52
  requirements:
38
53
  - - ">="
@@ -42,5 +57,6 @@ requirements: []
42
57
  rubygems_version: 3.5.20
43
58
  signing_key:
44
59
  specification_version: 4
45
- summary: A script to rename batch of files
60
+ summary: A command-line gem to rename batch of files using regex, and sequential numbering
61
+ capabilities.
46
62
  test_files: []