Auto-rename files during copy process

What is the problem you are having with rclone?

I'm trying to copy folders from Google Drive to a local Windows folder but there are files that have the same file name within some of the Google Drive folders. Windows does not allow files to have the same name so rclone is throwing up an error. I have explored the DEDUPE function but that seems designed to rename the conflicting files in the source Google Drive. I'm wondering if there's anyway to have rclone autorename the files when they are copied locally, e.g file(1), file(2), file(3).

I've tried mounting the Google Drive as a drive letter but thru Windows Explorer i only see 1 copy of the file even though there are multiple copies visible when accessing via Google Drive web.

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

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)


Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

[GDRIVE]
type = drive
token = XXX
team_drive =

A log from the command that you were trying to run with the -vv flag

Paste  log here

welcome to the forum,

rclone does not auto-rename files.
lol, try --magic

i think you would need to write a script to handle that and perhaps some trickery.
note that rclone lsf can list with duplicate filenames and the id of the objects.

and unless you solve this, you will always run into this problem.

@Yaniv_Schiff

  1. using rclone lsf it is possible to get file name (duplicates possible) and object ID (unique):
$ rclone lsf --format "pi" gdrive_remote:
file_name_1;XYZ_ID
file_name_1;ABC_ID

  1. Object ID (XYZ_ID) can be used in copy operations using gdrive backend specific copyid command:
$ rclone backend copyid gdrive_remote: "XYZ_ID" /path/to/dest/new_file_name

rest is just recursive directories listing and some logic to add prefix/suffix to duplicated names

If you get it working please share in HowTo Guides - definitely would be useful for others.

Thanks for the suggestion. After testing what I'm seeing is that rclone creates a NEW folder with the updated file name, then places the originally named file into the new folder. I don't see a way to force rclone to save the destination file using the new file name.

-update-
using the copyto command rather than copy fixed this.

Here's what i ended up doing.

  1. Ran the standard copy job and created a log file for the errors
  2. Searched the log file for the duplicate file errors and put into excel
  3. used Excel and Notepad++ to append a unique number to the end of each of duplicate file
  4. created rclone command for each of the duplicative file names.

e.g.
./rclone copyto gdrive:/folder1/file.pdf d:/gdrive/folder1/file(2).pdf

1 Like