I'm trying to understand how to best handle copying a folder with multiple files with the same name from Google Drive to my local machine. In some cases, three or more files will have the same name.
I am not the owner of the Google Drive share, and cannot run rclone dedupe
Also, as I understand, the suffix flag only works once, so if I use suffix .old, if there are three files with the same name, I'll only get two copies, correct?
Is there a way to instruct rclone to use a different suffix per file encountered (like old.1, old.2, etc)?
Run the command 'rclone version' and share the full output of the command.
rclone v1.56.2
- os/version: Microsoft Windows 10 Pro 2009 (64 bit)
- os/kernel: 10.0.19045.3324 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.16.8
- 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)
Note: I didn't actually run the command yet - the folder is large and I wanted to understand the behavior before I started the copy (and potentially had to handle duplicates manually).
This is very old version of rclone - update to the latest one to avoid some already fixed old issues.
What flag are you talking about? Maybe I am missing something but I have never heard about such option for duplicates.
Nope
The question is what you want to achieve. Do you want to preserve all duplicates? (as old1, old2 etc) or you know that they are all the same so you want to deduplicate them first?
What flag are you talking about? Maybe I am missing something but I have never heard about such option for duplicates.
The --suffix flag allows you to specify that, if a file would be overwritten by something in the copy, apply a suffix first. So if there were multiple copies of fileA.png and I used --suffix "-new", the first would be written as fileA.png and the second would be fileA.png-new.
It was brought up in another thread about this problem.
That doesn't help me though, given there are sometimes three or four files that have the same name, and the suffix is applied only once (if fileA.png-new already exists, it will overwrite it rather than generate fileA.png-new-new).
I was hoping there was a way to do something like what Chrome/Firefox do with downloads and apply a numbered suffix that incremented with each copy.
Do you want to preserve all duplicates? (as old1, old2 etc)
Yes, that's the goal - I'm trying to archive everything in the shared folder, and there are multiple images that have the same names.
Ahh OK. Got it now. Yes it only works for two copies.
This does not exist today but indeed it would be useful in cases like this.
But there is solution you can try.
rclone lsf --format "pi" drive: - this will give you list of all files with their full paths and unique gdrive IDs
Loop over the list from the previous step and copy files using their IDs - rclone backend copyid drive: ID dest_path. It can be simple bash script where you detect that dest_path already exist so you add prefix 1 - if exist too prefix 2 etc.
If you have a lot of files you can rclony copy everything first (duplicates won't be copied) and then use described method only to process duplicated files.