From a2dfb86359ceb136239f6d8085b88b960b252a8c Mon Sep 17 00:00:00 2001 From: Kenneth Odle Date: Mon, 24 Aug 2026 08:27:10 -0400 Subject: [PATCH] =?UTF-8?q?Added=20=C2=ABmmv=C2=BB=20to=20Files=20chapter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chapters/ch03-files.tex | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/chapters/ch03-files.tex b/chapters/ch03-files.tex index 292d997..7cc0820 100644 --- a/chapters/ch03-files.tex +++ b/chapters/ch03-files.tex @@ -10,6 +10,44 @@ fooabi.txt foo38r.txt \end{Verbatim} +To remove the ``foo'', use this command: + +\begin{Verbatim}[] +mmv 'foo*' '#1' +\end{Verbatim} + +To change ``foo'' to ``bar'', use: + +\begin{Verbatim}[] +mmv 'foo*' 'bar#1' +\end{Verbatim} + +The \texttt{mmv} command uses this command structure: + +\begin{Verbatim}[] +mmv [-m|x|r|c|o|a|l|s] [-h] [-d|p] [-g|t] [-v|n] [--] [from to] +\end{Verbatim} + +For a full discussion of those, see the ``man'' page. The key concept here is that wildcard characters in the ``from'' option get replaced with ``\#1'', ``\#2'' etc in the ``to'' option, in the order they are encountered. So it is possible to reorder elements of file names. For example, to exchange ``foo'' in our list above for the file extension, we would use: + +\begin{Verbatim}[] +mmv 'foo*.txt' 'txt#1.foo' +\end{Verbatim} + +To reverse the order of the last three characters of the filenames, we would use: + +\begin{Verbatim}[] +mmv 'foo???.txt' 'foo#3#2#1.txt' +\end{Verbatim} + +That would produce this list of files:\index{mmv} + +\begin{Verbatim}[] +foo341.txt +fooiba.txt +foor83.txt +\end{Verbatim} + \lettrine{T}{his} can also be accomplished by using the \textbf{rename}\index{rename} command. \section{Obtain a List of Files and their Paths}