Filter question

Hi there, question! Given this script:

#!/bin/bash
set -euox pipefail
clear

d=~/Desktop/test
rmtrash "${d}"

mkdir -p "${d}/dir1"
mkdir -p "${d}/dir2"
mkdir -p "${d}/dir3/subdir3-a"
touch "${d}/file1.txt"
touch "${d}/dir1/file2.txt"
touch "${d}/dir2/file3.txt"
touch "${d}/dir3/file3.txt"
touch "${d}/dir3/subdir3-a/file4.txt"

rclone -v --filter "+ dir3" ls "${d}"

it produces this output:

$
+ d=/Users/david/Desktop/test
+ rmtrash /Users/david/Desktop/test
+ mkdir -p /Users/david/Desktop/test/dir1
+ mkdir -p /Users/david/Desktop/test/dir2
+ mkdir -p /Users/david/Desktop/test/dir3/subdir3-a
+ touch /Users/david/Desktop/test/file1.txt
+ touch /Users/david/Desktop/test/dir1/file2.txt
+ touch /Users/david/Desktop/test/dir2/file3.txt
+ touch /Users/david/Desktop/test/dir3/file3.txt
+ touch /Users/david/Desktop/test/dir3/subdir3-a/file4.txt
+ rclone -v --filter '+ dir3' ls /Users/david/Desktop/test
2017/04/22 22:48:10 INFO  : Local file system at /Users/david/Desktop/test: Modify window is 1s
        0 file1.txt
        0 dir1/file2.txt
        0 dir3/subdir3-a/file4.txt
        0 dir2/file3.txt
        0 dir3/file3.txt
$

However, i assumed it would only output the “/Users/david/Desktop/test/dir3” folder and its contents & subfolders.
Why not? And what’s the correct rclone command to only show the “dir3” folder & contents?

Thanks! :slight_smile:

PS.
I should mention that my end goal was to copy the “dir3” folder (including all its contents) to a remote.
rclone copy ./dir3 remote:/somefolder/
didn’t work because it only copies the contents of dir3, and not the dir3 folder itself :’(

Anchor dir3 to the root.

rclone -v --include ‘/dir3/**’ ls /Users/david/Desktop/test

1 Like