I used the straightforward
$ gam UserA transfer ownership [FolderID] UserB
I suspect the inherent difficulty in parallelisation lies in having to make sure files and folders are shared before transferring, maintaining execution order down branches to set the correct parent folder and taking asynchronicity into account.
For me personally, I will experiment with more commands in different session to transfer branches rather than full trees.
As an aside for a possible implementation: under the assumption you can access a list of IDs that share a parent folder (i.e. contents of a folder) maybe you could use a recursive algorithm:
- (using pool of threads of size MAX_THREADS or whatever -- the usual batching facility)
- (File ID as sole input)
- Wait for available thread from pool
- If it is a File --> check if excluded by any of the options to the gam command --> process --> release threadlock.
- If it is Folder --> unless excluded, transfer folder --> grab a list of folder contents --> release threadlock --> call self on each item in this folder.
I suppose you would preparse the file set for inclusion / exclusion and use a flag to indicate that preparsing has already been done. This way, the parallellisation scales up or down to the limit of THREAD_POOL_SIZE. It isn't 'pure' parallel batching because the division is across folder branches rather than fixed size batches (so a very large folder with many files will still take a long time) but given a typical dataset I expect significant speed gains.
In case of API failures, maybe mark the IDs with a failure code and set a flag. Check for the flag at the end of the whole loop and reprocess the failures that might be transient issues.
(just my $0.02 -- ignore at will)