FileZilla Pro CLI: Filter Files and Directories

FileZilla Pro Command Line allows you to apply filters when executing commands that impact files
and directories.

Commands that can add filters are: ls, lls, mget, mput, mdel, lmdel, mrn, lmrn, rget, rput and sync.

To add filters, those commands use the –-exclude option.

The --exclude option takes an argument in the form:

    type condition value

Note that the argument should be enclosed in quotation marks.

Here is a breakdown of the available types and conditions:

    name: apply the filter to the name of the file, including its extension
    size: apply the filter to the file size
    perm: apply the filter to the file attributes
    path: apply the filter to the names of the directory and subdirectories the file is located
    date: apply the filter to the date on which the file was created or last modified

Name and path

For types name and path, value is a string and the condition can be set to:

    has: whether the name of a file or directory includes the text
    hasnot: filters files and directories that do not include the text in the name
    =: whether the name of a file or directory exactly matches the text
    begins: whether the name of a file or directory starts with the text
    ends: whether the name of a file or directory ends with the text
    rx: if the name of a file matches a regular expression

Size

For type size, value is a numerical size and the condition can be set to:

    >: filter files larger than the specified size
    =: filter files at the specified size
    !=: filter files that are not of the specified size
    <: filter files smaller than the specified siz

If value contains spaces, enclose it with escaped quotation marks.

Permission

For type perm, the condition can be set to:

    set: filter files which specified attributes are set
    !set: filter files which specified attributes are not set

and the value is a string representing the file or directory attributes in the format rwxrwxrwx, where

    r: the attribute allows reading
    w: the attribute allows writing
    x: the attribute allows executing

Each triplet rwx in the value string represents user, group, and all access.

Date

For type date, the condition can be set to:

    >: filter files created or modified after the specified date
    =: filter files created or modified on the specified date
    !=: filter files whose create or last modified date is not the specified one
    <:filter files created or modified before the specified date

and the value is a string representing a timestamp in the format YYYYMMDD[HHMMSS]

Multiple filters

You can use multiple --exclude options to provide several filters.

The --match option takes an argument to specify how the multiple filters are handled. It takes one argument that can be:

    all: filters out items matching all the filters (the default)
    notall: filters out items that don’t meet the criteria of one or more filters
    none: filters out items that don’t meet the criteria of all filters
    any: filters out items that meet criteria of any filte

Examples

Exclude all files whose name begins with DESC:

    --exclude "name begins DESC"

Exclude all files whose path contains My Documents:


    --exclude "path has \"My Documents\""

Exclude all files that match the regular expression .*2023\..* (note how \ is escaped twice, see Escape Sequences):

    --exclude "name rx \".*2023\\\\..*\""

Exclude all files whose size is greater than 20000:

    --exclude "size > 20000"

Exclude all files whose creation or last modified date is after December, 31st 2023:

    --exclude "date > 20231231"

Exclude all files whose permission is set as executable for user, group, and all:


    --exclude "perm set -x-x-x"

Exclude all files whose creation or last modified date is before March, 1st, 2023 and ending with bak:

    --exclude "date < 20230301" --exclude "name ends bak"

Exclude all files whose creation or last modified date is before March, 1st, 2023 and all files ending
with bak:

    --exclude "date < 20230301" --exclude "name ends bak" --match any

Do not exclude files whose creation or last modified date is before March, 1st, 2023 and whose name
ends with bak:


    --exclude "date < 20230301" --exclude "name ends bak" --match notall

Do not exclude files whose creation or last modified date is before March, 1st, 2023, or files whose
name ends with bak:

    --exclude "date < 20230301" --exclude "name ends bak" --match none

The video tutorial below shows the utilization of filters with FileZilla Pro CLI.

Video tutorial: How to Use Filters with FileZilla Pro CLI

Tags: , , ,