Sorry, that's my mistake they were meant to be copied over as well.
It would actually be:
Remove the local file in the folder of the same name
Move the file on the server within the same folder name as the one on the local disk and then remove the folder and file from the server.
Some folders will have spaces in them, is it difficult to get it to work with spaces? Would that command just be copied and pasted into the command prompt?
Also, for it to run automatically is that done with Task Scheduler? I currently have a WinSCP script running that only copies files and that is done by having a .txt file with the commands and then creating a .bat file with the following in:
winscp.com /script=SyncToLocalScript.txt
exit
Would it be the same or does rclone have a different way?
Great! Thanks for confirming. I asked @ncw said it wouldnāt work with spaces.
Oh I see, the Linux one could be handy anyway as Iām possibly going to get a Synology NAS which is Linux. I wasnāt aware that the commands would be different on each OS.
Also, is it easy to convert to Powershell? Can I use an online service to do it?
ok, i guess i did your ask and did not see his answer.
rclone ls "d:\d i r\f i l e.txt"
1 f i l e.txt
i have access to a bunch of synboxes, rclone runs great on it.
it depends on your script skills or perhaps now is a great time to learn to script.
the bash script, with a few minor path tweaks, will run on WSL - WIndows Subsystem for Linux
So, to confirm⦠I just need to use the quote symbol for spaces to be ok?
My skills are pretty much nonexistent. I know some ssh commands like ls but thatās only because Iāve been told to do it when needed.
I do actually have access to a book on Powershell as my brother was learning it so I might have to get it from him and read it but I imagine itās quite a steep learning curve.
I can see if he will be able to but I don't think he is great at it but I will see what he says. If not it would still be awesome if someone else who may know Powershell in the forum could help out.
Another is to save it in a file, with extension .ps1. Then execute that file using something like this:
powershell.exe filename.ps1
Either from a command prompt, from Windows Run (Win+R), or you can create a Windows shortcut to run that.
Beware of relative file paths, as current directory may vary with different methods - and especially if you run PowerShell as administrator as it will default to C:\Windows\system32 as current directory, which has great potential for wrecking your windows install if run the wrong command with relative paths...
Depending on your setup, you might have to enable the possibility to execute PowerShell scripts from file. This can be done by starting PowerShell as administrator and execute the following:
Set-ExecutionPolicy RemoteSigned
Do that once, and close the PowerShell instance, and it is permanently changed.
This thread have same topic what im looking for, so with the author permission im gonna ask same question,
I need to move one folder that have many subfolder and and every subfolder have many files, so below cmd will be ok?
I tried copying and pasting it into PowerShell but it didn't work so I saved the file as SyncToLocal.ps1 and right clicked in chose to Run with PowerShell.
It does look like it worked though, however, one file in a folder was copied across but not deleted and how can I add to delete empty directories on the remote?
Ah, yes, if the local directories may or may not exist you can add -ErrorAction Ignore to the Remove-Item command. And to avoid empty directories being left behind in remote, add --delete-empty-src-dirs to the rclone move command, like this:
I haven't used that option much myself, but seems it only deletes empty subdirectories (when the move is not server-side). To fix that you could add another command, after the rclone move:
rclone rmdir "${RemoteRoot}/${_}" 2>&1 | Out-Null
Which should be a safe thing to do, as it:
Will not remove the path if it has any objects in it, not even empty subdirectories
Note that the approach we have so far leaves some corner cases not being handled:
rclone rmdir command above will hide any errors as a result of the directory existing but could not be deleted, e.g. because it was not empty after all. But if this were to happen, the previous rclone move command above should have reported errors, I think.
The Remove-Item command with -ErrorAction Ignore is similar: If it fails for other reasons than the path not exists, e.g. you do not have permissions, you will not notice, and the script will continue with the rclone move into the destination that already exists. But if you had no permissions to the destination, this move operations should fail as well, and it will report errors..
These may or may not be relevant in your case, depending on things like paths used, permissions, admin privileges, your level of paranoia... The points mentioned above are not very difficult to improve, but it makes the script a bit more complex (i.e. hard to read).
Thanks, I tried adding that and it deleted everything from the server and local.
If I run the script again (the one below) and if the empty folders on the server are still there it deletes the folders on my local computer even if there's a file in the folder.
Well, that command alone did not do that. Did you start out with "clean" test case, no empty subdirs remaining from previous attempts etc..?
I haven't really followed this thread in detail from start, but migrated the suggested script to powershell, and think it should be equivalent as of now. If it does not do what you want, could you give some details of what it is doing and what you want it to do..
I did a clean test and then tested it again after by adding one new file into a folder on the server with the empty folders and it moved the file across to the relevant folder but deleted all the others on local.
This is what I'm hoping to achieve...
I have a server that has multiple files in folders that are always changing. New files and folders are added regularly (I don't know what the names of the folders or files will be before hand).
So, what I would like to be able to do is to download the files within a specific folder (with loads of other folders and files in) to my computer. For example, the folder structure could be...
Folder Name
Sub Folder 1
File 1
Sub Folder 2
File 2
Sub Folder 3
File 3
Sub Folder 4
File 4
and so on... When that has finished downloading, I would like to be able to delete any existing files on my computer within the folders (only delete the files and not the folders on my computer) and I would also like the source files and folders to be deleted from the server and if possible to have this run automatically.
This is how the before and after folders would look like...
Server before
Folder Name
Sub Folder 1
File 1
Sub Folder 2
File 2
Sub Folder 3
File 3
Sub Folder 4
File 4
Local Computer Before
Folder Name
Sub Folder 1
File 11
Sub Folder 2
File 23
Sub Folder 55
File 98
Sub Folder 65
File 74
Sub Folder 100
File 185
Sub Folder 33
File 478
Sub Folder 879
File 444
Sub Folder 15
File 667
Server After
Folder Name
Local Computer After
Folder Name
Sub Folder 1
File 1
Sub Folder 2
File 23
Sub Folder 3
File 3
Sub Folder 4
File 4
Sub Folder 55
File 98
Sub Folder 65
File 74
Sub Folder 100
File 185
Sub Folder 33
File 478
Sub Folder 879
File 444
Sub Folder 15
File 667
On the Local Computer After, it will always have more folders than the server as all files downloaded from the server should be deleted and any files within the sub folders before should be removed when downloading a new file.