aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-10 18:00:13 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-10 18:00:13 +0200
commitba5414545ed0cbce19bd305c5c21c4d159ef852f (patch)
tree2c5a4cea4beed814fdcd73de864a75aa2aad7db2
parent44cae05186a6ae98c57fad69ecd0cf90463a1f8f (diff)
downloadre-name-ba5414545ed0cbce19bd305c5c21c4d159ef852f.tar.gz
Add re.1, name.1
-rw-r--r--Makefile4
l---------name.11
-rw-r--r--re.182
3 files changed, 87 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 74da858..64c8b21 100644
--- a/Makefile
+++ b/Makefile
@@ -1 +1,5 @@
all: re name
+
+install:
+ install re name /usr/local/bin
+ install -m 644 re.1 name.1 /usr/local/man/man1
diff --git a/name.1 b/name.1
new file mode 120000
index 0000000..159d8f0
--- /dev/null
+++ b/name.1
@@ -0,0 +1 @@
+re.1 \ No newline at end of file
diff --git a/re.1 b/re.1
new file mode 100644
index 0000000..1bb1ae0
--- /dev/null
+++ b/re.1
@@ -0,0 +1,82 @@
+.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
+and
+.Nm name
+do not support file names containing newlines
+and will exit if provided with such file names.
+.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 mulitple bulk renames
+from the same shell process.
+Note that sub-shells retain the process id of their parent.