1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
.\" ========================
.\" ===== ===============
.\" ====== ================
.\" ====== ================
.\" ====== ==== ==== ==
.\" ====== === == = =
.\" ====== === = == =
.\" = === === = == ====
.\" = === === = == = =
.\" == ===== ==== ==
.\" ========================
.\"
.\" SPDX-License-Identifier: BSD-3-Clause
.\"
.\" Copyright (c) 2020 Joe
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the organization nor the
.\" names of its contributors may be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY JOE ''AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
.\" DISCLAIMED. IN NO EVENT SHALL JOE BE LIABLE FOR ANY
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" unixize: man/unixize.1
.\" Fri Nov 27 22:55:32 CET 2020
.\" Joe
.\"
.\" Manpage for unixize.
.\" Contact rbousset@42lyon.fr to correct errors and typos.
.\"
.de Text
.nop \)\\$*
..
.de squoted_text
.Text \\$3\(oq\fB\\$1\f[]\(cq\\$2
..
.de dquoted_text
.Text \\$3\(lq\fB\\$1\f[]\(rq\\$2
..
.de file_example
.PP
.RS
\`\\$1\' \-\> \`\\$2\'
.RE
.PP
..
.
.
.TH unixize 1 "27 November 2020" "unixize 1.0"
.
.
.SH NAME
.B unixize
\- bulk rename directory contents
.
.
.SH SYNOPSIS
.SY unixize
.RB [ \-ahiknprRv ]
[\c
.BI \-e ext\c
]
.I directory
.YS
.
.
.SH DESCRIPTION
.PP
The
.B unixize
utility renames all file in a given
.I directory
to a predefined style. Here is a description of the
.B unixize
behaviour without options. This behavious can be changed using options, see
\(lqOPTIONS\(rq below. By default:
.
.PP
.
All upper-case characters will be set to lower-case.
.
.file_example "FILE" "file"
.
Spaces will be substitued by a
.BR separator ,
by default underscores
.squoted_text _ ). (
.
.file_example "a file with spaces.org" "a_file_with_spaces.org"
.
Multiple spaces will be condensed into only one
.BR separator .
.
.file_example "lots of spaces.gif" "lots_of_spaces.gif"
.
By default the
.BR "opposite separator"
is hyphen
.squoted_text - ). (
All
.BR "opposite separator"
will be changed to the chosen
.BR separator ,
underscores
.squoted_text _ ) (
by default.
.
.file_example "2004-with-the-lights-out" "2004_with_the_lights_out"
.
All unicode characters will be deleted
except for latin extended ascii characters, which will be replaced by the most
relevant ascii character (or double characters).
.
.file_example "\(EuHliðskjálf\(de\(dd.jpg" "hlidhskjalf.jpg"
.
Two special patterns are always substitued, regardless of options.
.PP
The first sequence is
.dquoted_text C\+\+ ,
which will always be changed to
.dquoted_text cxx
whether the letter
.squoted_text C
is upper-case or lower-case.
.
.file_example "learn_c++_programming.pdf" "learn_cxx_programming.pdf"
.
The second one is the special case where the filename begins with a number,
followed directly by a dot
.squoted_text . ) (
and another dot
.squoted_text . ) (
can be found later in the filename (for example the file's extension). In this
case, the first dot is removed.
.
.file_example "07. Negative Creep.flac" "07_negative_creep.flac"
.
If another dot
.squoted_text . ) (
can't be found, nothing is changed.
.
.file_example "255.sql" "255.sql"
.
In the case where the renamed version of a file is already present in the
.I directory
(for example if \(lqREADME\(rq is being unixized but another \(lqreadme\(rq
already exists), or if the renamed version is empty of text, the renaming of
this file will be skipped.
.SH OPTIONS
.TP
.B \-a
Include directory entries whose names begin with a dot
.squoted_text . ). (
.TP
.BI \-e\c ext
Unixize certain file extensions.
.I ext
can be either
.IR 0 ,
.I 1
or
.IR 2 .
Some file extensions are often prefered over other ones to specify the same file
type in UNIX-like operating systems. With
.I ext
set to
.IR 1 ,
.dquoted_text .asm
extensions will be changed to
.dquoted_text .S ,
.dquoted_text .cpp
extensions will be changed to
.dquoted_text .cc ,
.dquoted_text .hpp
extensions will be changed to
.dquoted_text .hh
and
.dquoted_text .txt
files will see their extension removed. When
.I ext
is set to
.IR 2 ,
all the previous rules are applied as well except that
.dquoted_text .cpp
extensions will be changed to
.dquoted_text .cxx
and
.dquoted_text .hpp
extensions will be changed to
.dquoted_text .hxx .
Default:
.IR 0 .
.TP
.B \-h
Output a brief help message.
.TP
.B \-i
Prompt user before running
.B unixize
on the specified directory. If the
.B \-R
option is being used, the user will be prompted for each subdirectory the
program is entering.
.TP
.B \-k
Keep the opposite separator occurences in the filename. If the
.B \-n
option is not being used, all existing hyphens
.squoted_text - ) (
will be preserved. Otherwise, all existing underscores
.squoted_text _ ) (
will be kept.
.RS 12
\`screen 2020-10-21.mkv\' \-\> \`screen_2020-10-21.mkv\'
.RE
.TP
.B \-n
Use hyphens
.squoted_text - ) (
instead of underscores
.squoted_text _ ) (
as a
.B separator
and sets underscores as the
.BR "opposite separator" .
.RS 12
\`04 School.mp3' \-\> \`04-school.mp3\'
.RE
.RS 12
\`11-27_958x1078_scrot.png\' \-\> \`11-27-958x1078-scrot.png\'
.RE
.TP
.B \-p
Pretend only.
.B unixize
will run normally but will not actually rename any file. This
option is intended to be used with the
.B \-v
and/or
.B \-r
options.
.TP
.B \-R
Recursive mode. The program will enter and repeat into every subdirectories.
.TP
.B \-r
Reverse verbose mode. Files that are not being renamed will be displayed to
stdout.
.TP
.B \-v
Verbose mode. File that are being renamed will be displayed to to stdout as well
as their new version.
.
.SH BUG REPORT
Please note that
.B unixize
was tested only on FreeBSD at the moment. Linux and macOS tests are coming soon.
You can report bug at
.I rbousset@42lyon.fr
or on GitHub at
.I https://github.com/JozanLeClerc/unixize/issues
or on Chisel
.IR https://chiselapp.com/user/JozanLeClerc/repository/unixize/ticket .
.
.SH SEE ALSO
.IR ascii (7),
.IR ls (1),
.IR tree (1),
.IR rename (2)
.\" vim: set filetype=groff:
|