-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathslugify.1
336 lines (318 loc) · 5.48 KB
/
slugify.1
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "SLUGIFY" "1" "January 2016" "" ""
.
.SH "NAME"
\fBslugify\fR \- convert filenames and directories to a web friendly format
.
.SH "SYNOPSIS"
\fBslugify\fR [\-acdhintuv] \fIsource_file\fR \.\.\.
.
.SH "DESCRIPTION"
\fBSlugify\fR converts filenames and directories to a web friendly format\. Before running any command, consider a dry run \fB\-n\fR before hand\.
.
.P
Options include:
.
.TP
\fB\-a\fR
Remove spaces immediately adjacent to dashes\.
.
.TP
\fB\-c\fR
Consolidate consecutive spaces into single space\.
.
.TP
\fB\-d\fR
Replace spaces with dashes (instead of default underscores)\.
.
.TP
\fB\-h\fR
Display help\.
.
.TP
\fB\-i\fR
Ignore case\.
.
.TP
\fB\-n\fR
Dry run\.
.
.TP
\fB\-t\fR
Treat existing dashes as spaces\.
.
.TP
\fB\-u\fR
Treat existing underscores as spaces (useful with \fB\-a\fR, \fB\-c\fR, or \fB\-d\fR)\.
.
.TP
\fB\-v\fR
Verbose mode\.
.
.SH "EXAMPLES"
Note, most examples below are run in verbose mode (\fB\-v\fR) to help illustrate the results\. Verbose mode is unnecessary in real world scenarios\.
.
.P
\fBProvide escaped filenames:\fR
.
.IP "" 4
.
.nf
$ slugify \-v My\e \e file\.txt
rename: My file\.txt \-> my__file\.txt
.
.fi
.
.IP "" 0
.
.P
\fBAlternatively provide unescaped filenames inside quotes:\fR
.
.IP "" 4
.
.nf
$ slugify \-v "My file\.txt"
rename: My file\.txt \-> my__file\.txt
.
.fi
.
.IP "" 0
.
.P
\fBGlobs (like * and ?) work as well:\fR
.
.IP "" 4
.
.nf
$ slugify \-v *\.txt
rename: My file\.txt \-> my_file\.txt
ignore: my_web_friendly_filename\.txt
.
.fi
.
.IP "" 0
.
.P
\fBProvide an unlimited number of arguments:\fR
.
.IP "" 4
.
.nf
$ slugify \-v "My first file\.txt" "My second file\.txt"
rename: My first file\.txt \-> my_first_file\.txt
rename: My second file\.txt \-> my_second_file\.txt
.
.fi
.
.IP "" 0
.
.P
\fBDirectories are also supported:\fR
.
.IP "" 4
.
.nf
$ slugify \-v "My Directory"
rename: My Directory \-> my_directory
.
.fi
.
.IP "" 0
.
.P
\fBConsolidate consecutive spaces into single spaces:\fR
.
.IP "" 4
.
.nf
$ slugify \-vc "My consolidated file\.txt"
rename: My consolidated file\.txt \-> my_consolidated_file\.txt
.
.fi
.
.IP "" 0
.
.P
\fBReplace spaces with dashes:\fR
.
.IP "" 4
.
.nf
$ slugify \-vd "My dashed file\.txt"
rename: My dashed file\.txt \-> my\-dashed\-file\.txt
.
.fi
.
.IP "" 0
.
.P
The \-d option replaces each space with a dash\.
.
.IP "" 4
.
.nf
$ slugify \-vd "My dashed file\.txt"
rename: My dashed file\.txt \-> my\-\-dashed\-\-file\.txt
.
.fi
.
.IP "" 0
.
.P
Combine \fB\-d\fR with \fB\-c\fR (consolidate spaces) for a single dash between each word\.
.
.IP "" 4
.
.nf
$ slugify \-vdc "My dashed file\.txt"
rename: My dashed file\.txt \-> my\-dashed\-file\.txt
.
.fi
.
.IP "" 0
.
.P
\fBIgnore case:\fR
.
.IP "" 4
.
.nf
$ slugify \-vi "UPPER CASE FILE\.txt"
rename: UPPER CASE FILE\.txt \-> UPPER_CASE_FILE\.txt
.
.fi
.
.IP "" 0
.
.P
\fBPlay it safe with a dry run:\fR
.
.P
Dry run mode does not alter the filesystem in any way\.
.
.IP "" 4
.
.nf
$ slugify \-n *
\-\-\- Begin dry run mode\.
rename: My file\.txt \-> my_file\.txt
ignore: web_friendly_filename\.txt
\-\-\- End dry run mode\.
.
.fi
.
.IP "" 0
.
.P
Dry run mode also allows you to test filenames that don\'t exist\. Great for testing!
.
.IP "" 4
.
.nf
$ slugify \-n "Ghost File\.txt"
\-\-\- Begin dry run mode\.
not found: Ghost File\.txt
rename: Ghost File\.txt \-> ghost_file\.txt
\-\-\- End dry run mode\.
.
.fi
.
.IP "" 0
.
.P
Dry run mode automatically enables verbose mode so there is no need to include the \fB\-v\fR option with \fB\-n\fR\.
.
.P
\fBHandle spaces adjacent to dashes:\fR
.
.P
In this example, without \fB\-a\fR the dashes end up surrounded by underscores\.
.
.IP "" 4
.
.nf
$ slugify \-v "The Beatles \- Yellow Submarine\.mp3"
rename: The Beatles \- Yellow Submarine\.mp3 \-> the_beatles_\-_yellow_submarine\.mp3
.
.fi
.
.IP "" 0
.
.P
But with \fB\-a\fR the adjacent spaces are removed\.
.
.IP "" 4
.
.nf
$ slugify \-va "The Beatles \- Yellow Submarine\.mp3"
rename: The Beatles \- Yellow Submarine\.mp3 \-> the_beatles\-yellow_submarine\.mp3
.
.fi
.
.IP "" 0
.
.P
The \fB\-a\fR only removes spaces immediately adjacent to a dash, which may not be the desired effect (below three spaces on either side of the dash get converted into two underscores because of \fB\-a\fR)\.
.
.IP "" 4
.
.nf
$ slugify \-va "The Beatles \- Yellow Submarine\.mp3"
rename: The Beatles \- Yellow Submarine\.mp3 \-> the_beatles__\-__yellow_submarine\.mp3
.
.fi
.
.IP "" 0
.
.P
But \fB\-c\fR consolidates spaces into a single space and then \-a will remove the left over adjacent single spaces\.
.
.IP "" 4
.
.nf
$ slugify \-vac "The Beatles \- Yellow Submarine\.mp3"
rename: The Beatles \- Yellow Submarine\.mp3 \-> the_beatles\-yellow_submarine\.mp3
.
.fi
.
.IP "" 0
.
.P
\fBConvert existing underscores into dashes\fR
.
.P
The \fB\-u\fR treats underscores as spaces and \fB\-d\fR converts spaces into dashes\.
.
.IP "" 4
.
.nf
$ slugify \-vud "Spaces Dashes\-And_Underscores\.txt"
rename: Spaces Dashes\-And_Underscores\.txt \-> spaces\-dashes\-and\-underscores\.txt
.
.fi
.
.IP "" 0
.
.P
\fBConvert existing dashes into underscores\fR
.
.IP "" 4
.
.nf
$ slugify \-vt "Spaces Dashes\-And_Underscores\.txt"
rename: Spaces Dashes\-And_Underscores\.txt \-> spaces_dashes_and_underscores\.txt
.
.fi
.
.IP "" 0
.
.SH "BUGS"
\fIhttps://github\.com/benlinton/slugify/issues\fR
.
.SH "COPYRIGHT"
Slugify is Copyright (C) 2012 Ben Linton \fIhttps://github\.com/benlinton/slugify\fR
.
.SH "SEE ALSO"
man(1), manpages(5)