Move and Delete

What is the problem you are having with rclone?

This is a pre-use question so I'm not having any problems thus far. I am wondering if it is possible to download a file from FTP to my local computer and if there's already a file in that folder on my local computer delete the excisting file(s) as well as delete the file on the server. For example, on my local computer I have example.docx and on the FTP there's example-john-edit.docx, I want rclone to be able to download example-john-edit.docx to my local computer and delete example.docx from my local computer as well delete example-john-edit.docx on the server.

Is that possible? I've seen there's a move command but didn't see anything as specific as my needs.

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

N/A

Which cloud storage system are you using? (eg Google Drive)

FTP on a server

The command you were trying to run (eg rclone copy /tmp remote:tmp)

N/A

The rclone config contents with secrets removed.

N.A

A log from the command with the -vv flag

N/A

If you move from source to destination, it'll delete from the source and copy to the destination.

You can decide how you want to overwrite the destination. Generally, if the destination is different, it'll overwrite it. There are many parameters to tweak that behavior.

Easy enough to setup and test. Give it a try and see if it does what you want and if not, share what you did and what you want to happen and we can surely figure it out.

If I have it setup like the following... G:\Files\Documents\John\2022\ will it delete everything within the files folder or do I need to set something for it to not?

I'm new to all this so I need to research how to setup rclone as it's all command line and I've only used this sort of stuff with help/guides.

I will see if I can set it up and test and see how I get on.

Thanks for your reply :slight_smile:

It depends on what you use.

You can move the whole folder.
You can move one file.

There is a flag called --dry-run so you can test something (very good to use with a move or any destructive operation).

rclone move C:\Directory remote: would move the entire directory assuming "Directory" is actually a directory.

rclone move C:\Directory\afile.txt remote: would move one file.

Both of those can be tested with --dry-run

Ah OK cool, I'll give it a try.

Just gotta figure out how to configure it.

I have tried setting up rclone but not sure if I have done it correctly as I can't get anything to work.

Do I have to install rclone on my server rather than my local computer to get it to transfer files to my local computer as I am getting the following error...

2022/02/07 15:19:11 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found

That directory doesn't exist on my local computer as that's the directory on the server.

if you want to run rclone on your c:, then need to install rclone on that computer.

about that error, add -vv to the command, run the command, post the output.
enclose it with three backticks so it is formatted like this.

rclone version
rclone v1.57.0
- os/version: Microsoft Windows 10 Pro 2009 (64 bit)
- os/kernel: 10.0.22000.434 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.17.2
- go/linking: dynamic
- go/tags: cmount

I have rclone installed on my computer and I'm trying to transfer files from the server to my computer.

Here's the output from the command.


2022/02/07 15:49:34 DEBUG : rclone: Version "v1.57.0" starting with parameters ["C:\\rclone\\rclone.exe" "move" "/media/sdh1/matt3/test/hello.docx" "E:\\" "-vv"]

2022/02/07 15:49:34 DEBUG : Creating backend with remote "/media/sdh1/matt3/test/hello.docx"

2022/02/07 15:49:34 DEBUG : Using config file from "C:\\Users\\Matt\\AppData\\Roaming\\rclone\\rclone.conf"

2022/02/07 15:49:34 DEBUG : fs cache: renaming cache item "/media/sdh1/matt3/test/hello.docx" to be canonical "//?/C:/media/sdh1/matt3/test/hello.docx"

2022/02/07 15:49:34 DEBUG : Creating backend with remote "E:\\"

2022/02/07 15:49:34 DEBUG : fs cache: renaming cache item "E:\\" to be canonical "//?/E:/"

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Using server-side directory move

2022/02/07 15:49:34 INFO  : Local file system at //?/E:/: Server side directory move failed - fallback to file moves: can't copy directory - destination already exists

2022/02/07 15:49:34 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Waiting for checks to finish

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Waiting for transfers to finish

2022/02/07 15:49:34 ERROR : Attempt 1/3 failed with 1 errors and: directory not found

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Using server-side directory move

2022/02/07 15:49:34 INFO  : Local file system at //?/E:/: Server side directory move failed - fallback to file moves: can't copy directory - destination already exists

2022/02/07 15:49:34 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Waiting for checks to finish

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Waiting for transfers to finish

2022/02/07 15:49:34 ERROR : Attempt 2/3 failed with 1 errors and: directory not found

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Using server-side directory move

2022/02/07 15:49:34 INFO  : Local file system at //?/E:/: Server side directory move failed - fallback to file moves: can't copy directory - destination already exists

2022/02/07 15:49:34 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Waiting for checks to finish

2022/02/07 15:49:34 DEBUG : Local file system at //?/E:/: Waiting for transfers to finish

2022/02/07 15:49:34 ERROR : Attempt 3/3 failed with 1 errors and: directory not found

2022/02/07 15:49:34 INFO  :

Transferred:              0 B / 0 B, -, 0 B/s, ETA -

Errors:                 1 (retrying may help)

Elapsed time:         0.0s

2022/02/07 15:49:34 DEBUG : 2 go routines active

2022/02/07 15:49:34 Failed to move: directory not found

as per the error message,
rclone think that /media/sdh1/matt3/test/hello.docx" is a directory relative to c:\

renaming cache item "/media/sdh1/matt3/test/hello.docx" to be canonical "//?/C:/media/sdh1/matt3/test/hello.docx"

on windows, don't you need to use a netshare
\\server\share

Forgive me for being stupid but I've not understood what you mean.

I'm not too sure why it's thinking it's relative to C:. I think I have setup the rclone config correctly. Is there anyway I can test to make sure?

Thanks

perhaps if you can explain, in detail, what you are trying to do with that command?

so are running rclone on a windows computer and want to move files to it from a linux server?

I have installed rclone on my Windows computer so I can automatically download new files from a linux server to my computer.

I'm currently using a script with WinSCP which does work well but it doesn't delete any files that are already in the local directory.

If it helps, this is the current script I am using

option batch abort
option confirm off
open sftp://[username/password/host] -hostkey="[keyhere]"
get -delete "/media/sdh1/matt3/Files/*" "E:\Files"
exit

In short, I want to be able to download files from the server to my computer and have the file deleted from the server as well as delete any local files if there's already one in that folder, if not don't delete.

Hope that helps.

Thanks :slight_smile:

with rclone, create a sftp remote.
use that to transfer files from linux to windows.

I have already setup an SFTP remote (I think I did it correctly) but the command isn't working :frowning:

always test with a simple command.
rclone ls remote:

This is what I get when I run that command.

2022/02/07 16:33:28 Failed to create file system for "remote:": didn't find section in config file

change remote: to name of the sftp remote you created.

Oh Ok. I just did that and it's listed everything so looks like it has been setup correctly.

good, so now write a command and test it.

Still getting this error message

2022/02/07 16:43:52 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found
2022/02/07 16:43:52 ERROR : Attempt 1/3 failed with 1 errors and: directory not found
2022/02/07 16:43:52 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found
2022/02/07 16:43:52 ERROR : Attempt 2/3 failed with 1 errors and: directory not found
2022/02/07 16:43:52 ERROR : Local file system at //?/C:/media/sdh1/matt3/test/hello.docx: error reading source root directory: directory not found
2022/02/07 16:43:52 ERROR : Attempt 3/3 failed with 1 errors and: directory not found
2022/02/07 16:43:52 Failed to move: directory not found

Using this command...

 rclone move "/media/sdh1/matt3/test/hello.docx" "E:\Test\"