public function cmdDeleteFile()
    {
        $id = $this->getParam(0);
        $all = $this->getParam('all');

        if (empty($id) && empty($all)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $options = null;

        if (isset($id)) {

            if ($this->getParam('type')) {
                $options = array('file_type' => $id);
            } else if ($this->getParam('mime')) {
                $options = array('mime_type' => $id);
            } else if ($this->getParam('entity')) {
                $options = array('entity' => $id);
            }

        } else if (!empty($all)) {
            $options = array();
        }

        if (isset($options)) {

            $deleted = $count = 0;
            foreach ($this->file->getList($options) as $item) {
                $count++;
                $deleted += (int) $this->deleteFile($item);
            }

            $result = $count && $count == $deleted;

        } else {

            if (empty($id) || !is_numeric($id)) {
                $this->errorAndExit($this->text('Invalid argument'));
            }

            $result = $this->deleteFile($id);
        }

        if (empty($result)) {
            $this->errorAndExit($this->text('Unexpected result'));
        }

        $this->output();
    }