Accept directory names in --exclude-if-present

Hello

I often treat directory and file names interchangeable in copy operations (often with a leading ‘/’ but with roughly same meaning).

I want to copy all directories inside my projects directory but not the ones that are git tracked as they’d have git upstream.

Specifying a directory name in --exclude-if-present errors out:

$ rclone ls test --exclude-if-present '.git'

2025/08/13 03:49:59 ERROR : error listing: is a directory not a file
2025/08/13 03:49:59 NOTICE: Failed to ls with 2 errors: last error was: is a directory not a file

The error is not very clear about what is a directory and not a file, probably having an error like .git is a directory not a file would make more sense here anyway.

welcome to the forum,

afiak, as per the error, the value needs to be a file, not a directory.

Exclude directory based on a file


to exclude directories named .git, maybe somethihg like

rclone ls test -–exclude=’.git/**'

I do not want to exclude directories name .git, rather, I want to exclude directories containing a .git directory.

ie.

in the following dir structure

; ls test
node_modules  normal-file  python-project  repo  some-other-project
; tree -a -L2 test/repo
test/repo
├── .git
│   ├── HEAD
│   ├── config
│   ├── description
│   ├── hooks
│   ├── info
│   ├── objects
│   └── refs
└── abcd

I want test/repo to be excluded.

I don't think --exclude-if-present '.git/config' (path to a file) works either?

Sounds like this is something that could be improved, maybe you should create a github issue for it.

created! Accept directory names in –exclude-if-present · Issue #8745 · rclone/rclone · GitHub

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.