Copyto bug - when destination is a directory

What is the problem you are having with rclone?

copyto does something different than described in Docs.

rclone copyto Docs say:

rclone copyto src dst

then

if src is file
    copy it to dst, overwriting an existing file if it exists
if src is directory
    copy it to dst, overwriting existing files if they exist
    see copy command for full details

For the case where src is a file and dst is a directory:

- copyto  complains that  dst 
    <time stamp> ERROR : Attempt <x>/3 failed with 1 errors and: is a directory not a file

Working around it:

  • if you want the file copied to dst to have the same name as the one at src either:
    • make dst include the filename in the copyto parameters
    • use rclone copy instead.

Run the command 'rclone version' and share the full output of the command.

rclone v1.61.1

  • os/version: darwin 12.5.1 (64 bit)
  • os/kernel: 21.6.0 (arm64)
  • os/type: darwin
  • os/arch: arm64
  • go/version: go1.19.4
  • go/linking: dynamic
  • go/tags: none

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)

rclone copyto src dst

The rclone config contents with secrets removed.

[GooDrive]
type = drive
client_id = ...
client_secret = 
scope = drive
token = {"access_token":"...","token_type":"Bearer","refresh_token":"...","expiry":"..."}
root_folder_id = ...
team_drive = 

A log from the command with the -vv flag

2023/01/20 00:30:28 ERROR : Attempt 1/3 failed with 1 errors and: is a directory not a file
2023/01/20 00:30:28 ERROR : Attempt 2/3 failed with 1 errors and: is a directory not a file
2023/01/20 00:30:29 ERROR : Attempt 3/3 failed with 1 errors and: is a directory not a file
2023/01/20 00:30:29 Failed to copyto: is a directory not a file            

please post the full debug ouput

i believe that you need to specify the dest filename, like this
rclone copyto remote:file.ext remote:folder/file.ext

snippet from the source code

			if srcFileName == "" {
				return sync.CopyDir(context.Background(), fdst, fsrc, false)
			}
			return operations.CopyFile(context.Background(), fdst, fsrc, dstFileName, srcFileName)

You are correct. Including the file name in the destination does indeed work

Perhaps, all that's needed is clarification on that point in the Doc.

-jg-

yes, i agree. a github issue is needed. you are welcome to create it.

tho in the end, good that this is not a rclone bug

Issue submitted:

1 Like