aboutsummaryrefslogtreecommitdiff
path: root/re.1
blob: dabd53ee5834fa43ac12e453ce22230939108d15 (plain)
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
.Dd $Mdocdate$
.Dt RE 1
.Os
.Sh NAME
.Nm re
.Nd bulk rename with UNIX philosophy
.Sh SYNOPSIS
.Nm re
.Ar file
.Op Ar ...
.Nm name
.Op Fl x
.
.Sh DESCRIPTION
.Pp
.Nm re
and
.Nm name
are used in conjunction in order to bulk rename files.
.Pp
.Nm re
writes a number of file names, separated by newlines,
to a temporary file and on standard out.
.Pp
.Nm name
reads the original file names from the temporary file
and the new file names from standard in.
It prints the corresponding
.Xr mv 1
commands on standard out.
If given the
.Fl x
flag, it executes them as well.
.Pp
The idiomatic way to use
.Nm re
and
.Nm name
is to connect them with a pipe,
with arbitrary programs in-between.
.
.Sh EXAMPLES
.Pp
The following invocation changes the file extension of all mp3 files:
.Bd -literal -offset indent
$ re *.mp3 | sed 's/mp3$/m4a/' | name -x
.Ed
.Pp
The following invocation uses
.Xr ep 1
to manually edit the file names in
.Xr vi 1 :
.Bd -literal -offset indent
$ re * | ep | name
.Ed
.Pp
.Xr ep 1
is available for download at
.Lk http://git.ankarstrom.se/xutil/ .
.
.Sh AUTHORS
.Pp
.Nm re
and
.Nm name
are written by John Ankarström
.Aq Mt "john (at) ankarstrom.se" .
.
.Sh BUGS
.Pp
.Nm re
does not support file names containing newlines
and will exit with an error if provided with such file names.
.Pp
.Nm name
uses hard-coded array sizes:
at most, one hundred 255-character file names can be processed.
While overflows are correctly handled,
they are silently ignored.
When processing very many or very long file names,
the use of the
.Fl x
flag is not recommended.
.Pp
The temporary file is placed at
.Pa /var/tmp/re.$PPID ,
where $PPID is the process id of the parent shell.
This means that one cannot simultaneously perform multiple bulk renames
from the same shell process.
Note that sub-shells retain the process id of their parent.