I use rclone to sync from an external hard drive to Google Drive. I would like to stop rclone from syncing ._ files (generated by my Mac) to the Google Drive. I have already run rclone so the ._ files are already on Google Drive, so I would like to delete the ._ files that are already there and for rclone not to sync ._ files in the future. Furthermore I have ._init.py files that I do want to keep syncing. My first thought was to combine --exclude with --include:
--exclude '._*' --include '._init.py'
hoping that the --include flag would pull out the .init.py files that were excluded by the --exclude flag. However this gave me warning that I should use the filter command instead. It's not clear to me what the correct syntax should be for the filter command in my case. I tried
--filter '- ._*' '+ ._init.py'
but this threw an error that I have provided 3 non flag arguments
Run the command 'rclone version' and share the full output of the command.
rclone v1.55.1
os/type: darwin
os/arch: amd64
go/version: go1.16.3
go/linking: dynamic
go/tags: cmount
Which cloud storage system are you using? (eg Google Drive)
Google Drive
The command you were trying to run (eg rclone copy /tmp remote:tmp)
I'm not sure how to get this, hopefully not required, if it is, can someone advise?
A log from the command with the -vv flag
Usage:
rclone sync source:path dest:path [flags]
Flags:
--create-empty-src-dirs Create empty source dirs on destination after sync
-h, --help help for sync
Use "rclone [command] --help" for more information about a command.
Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.
Command sync needs 2 arguments maximum: you provided 3 non flag arguments: ["/sourcelocation" "remote:/destinationlocation" "+ .___init__.py"]
Many thanks for you help. Can you clarify what you mean by testing rclone with ls first? Do you mean replace 'rclone sync ....' with 'rclone ls .....' (with the .... being the flags as suggested in your post)?
Thanks for explanation. I've tried the code and whilst it's running, it is not deleting previously uploaded '._' files from my Google Drive (I mean the sync code). Any advice?
It looks like '--delete-excluded' does not see filtered files as excluded (before when I ran sync with --exclude --dry-run it was picking them up and was ready to purge them).
Can you advise if there is a way to automatically redact file and folder names? Obviously there are some privacy considerations sharing that information.
Thanks for the advice, I used your suggested code get rid of the ._ files from the Google Drive, but the issue remained that I didn't know what command to use to sync my local files without uploading ._ files whilst syncing .___init__.py files. In the end I found that the following worked:
That's why the debug log is key as it's much easier to figure out what the issue is.
The "," solution I gave works for include/exclude but not filter filter as that would have been evident in the debug log
If you follow what @asdffdsa was saying and use an include, it simplies things as the exclude all is automatically implied as seen by the filtering dump.