Example: Replicate Files From One Cloud Storage to Another

This is a simple script for the odrive CLI which will:

  1. Download files in the source link location (since you are not allowed to move placeholder cloud files).
  2. Mirror the files in the source link location to another. New files and changed files are copied, and deletes will also carry over to the destination.

If you were to schedule this script to run on a periodic basis, you could effectively automate replication of the contents of one cloud storage account to another cloud storage account.

# Powershell Script to copy files from one odrive storage link to another


# Check Prerequisites
if(!(Test-Path -Path $SYNCBIN)) {
    echo "Downloading CLI binary ... "
    (New-Object System.Net.WebClient).DownloadFile("https://dl.odrive.com/odrivecli-win", "$O\oc.zip")
    $shl=new-object -com shell.application
    del "$O\oc.zip"
    echo "Done!"
if (-Not ($SOURCEPATH) -or !(Test-Path -Path $SOURCEPATH)){
   echo "Missing or Invalid Source Path." 
if (-Not ($DESTPATH) -or !(Test-Path -Path $DESTPATH)){
   echo "Missing or Invalid Destination Path." 

# Download Source Path
echo "Downloading Source Path ... "
while ((Get-ChildItem -Path "$SOURCEPATH" -Filter "*.cloud*" -Recurse | Measure-Object).Count) {
   Get-ChildItem -Path "$SOURCEPATH" -Filter "*.cloud*" -Recurse | % { & "$SYNCBIN" "sync" "$($_.FullName)";}

# Copy from Source Path to Destination Path
echo "Copying ... "

echo "Done."

Learn how to configure your computer to run the script automatically.

Did this page help you?