How to rclone copy only .png files under a directory?

2.4k views Asked by At

I have lots of files under dir1/ in the server. I want to copy all the png files under dir1/*.png to google drive.

However

rclone copy dir1/*.png gdrive:dir2/

gives error.

Usage:
  rclone copy source:path dest:path [flags]

Flags:
      --create-empty-src-dirs   Create empty source dirs on destination after copy
  -h, --help                    help for copy

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 copy needs 2 arguments maximum: you provided 66 non flag arguments:

Is there a way to solve this issue?

2

There are 2 answers

0
burcak On

Ok, I have found a way to resolve this issue in another way around.

I used the --exclude flag.

In this way, I exclude the directory_I_do_not_want_to_copy_under_dir1 and all of its contents.

Therefore I copied the remaining under dir1/ including *.png files.

Not perfect but an approximate solution :)

rclone copy dir1/ gdrive:dir2/ --exclude==/directory_I_do_not_want_to_copy_under_dir1/**
1
igor_andreev On

"perfect" with --include :-)

rclone copy dir1/ gdrive:dir2/ --include "*.png"