Rename multiple files
To rename multiple files, use the mrn
(or mren
) command for remote files and lmrn
(or lmren)
) for local files.
mrn options [pattern]
lmrn options [pattern]
pattern
: optional regular expression to select which entries to rename. See Regular Expressions to learn more about regular expression syntax and Wildcards for the wildcard syntax.
Options:
To replace text in file names you have the following options:
-
--search, -s
: the text to be searched. --replace, -r
: the text that will replace the searched text.If this option is not specified, the search text is removed.-
--case, -c:
match case in searched text -
--regex, -x:
uses search text as a regular expression.
The options to add text in file names are:
-
--add, -a:
the text that will be added to the beginning of the file name. -
--end, -e:
the text that will be added to the end of the file name.
Common options:
--exists, e:
how to handle existing entries:– ignore, i:
new name is ignored, rename doesn’t take placeoverwrite, o:
existing entry is replaced. If you try to rename two or more entries with the same new name FileZilla Pro CLI returns an error and aborts the operation.number, n:
an incremental number is added to the new name.
--exclude
: exclusion condition. Files matching the condition are ignored. See Filter cFilter Files and Directories.
--match
: exclusion condition match type. See Filter Files and Directories.
Examples
- Replace
IMG
byDSC
in all JPEG files:
mrn --search IMG --replace DSC --exists number \.jpg$
- Rename
.docx
files to.bak
:
lmrn --regex --search \.docx$ --replace .bak --exists ignore
- Add
tmp
to the beginning of all files in the current directory:
mrn --add tmp --exists ignore
- Remove the
tmp
from the beginning:
mrn --regex --search ^tmp --exists ignore
The video tutorial below shows how to use the commands to rename multiple files with FileZilla Pro CLI.