How can I write batch sync command with a timestamp log file in Windows 10?

What is the problem you are having with rclone?

How can I write batch sync command with a timestamp log file in Windows 10? The command I've listed below does sync properly but the log file is written as rclone_$(get-date -f yyyy-MM-dd).log

Bonus Question: Is there a way to view the rclone sync progress (triggered by the command) when the batch script is running automatically from Task Scheduler? (Maybe a command that can "Watch" the batch script?)

What is your rclone version (output from rclone version)

rclone v1.53.3
- os/arch: windows/amd64
- go version: go1.15.5

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Windows 10

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)

:looper

rclone sync "C:/Users/XXX/google-drive" "gcrypt:/" --exclude node_modules/ --log-file "C:/Users/XXX/Documents/Rclone Latest Logs/rclone_$(get-date -f yyyy-MM-dd).log" --fast-list --verbose --stats 1m0s --progress

timeout /T 300 > nul
goto looper

You are running this from PowerShell, and not regular Command Prompt?

Sorry I didn't include the full script. The rclone commands run normally from both PowerShell and Command Prompt since I've added "rclone.exe" to the PATH.

You can now see the updated batch script in the OP.

This is a batch script, right? So it will be executed by cmd.exe, which does not understand the $(get-date -f yyyy-MM-dd).log, since this is powershell syntax. So you need to either change it to correct batch syntax:

rclone sync "C:/Users/alisa/google-drive" "gcrypt:/" --exclude node_modules/ --log-file "C:/Users/alisa/Documents/Rclone Latest Logs/rclone_%DATE%" --fast-list --verbose --stats 1m0s --progress

Or switch to powershell. To do that, as an example: Create a .ps1 file (e.g. sync.ps1) with content something like this:

while ($true)
{
    rclone sync "C:/Users/alisa/google-drive" "gcrypt:/" --exclude node_modules/ --log-file "C:/Users/alisa/Documents/Rclone Latest Logs/rclone_$(get-date -f yyyy-MM-dd).log" --fast-list --verbose --stats 1m0s --progress
    Start-Sleep -Seconds 300
}

Then execute it like this (replace path\to\sync.ps1 with your actual path and filename of course), e.g. as the command of your scheduled task:

powershell.exe -NoLogo -NoProfile -NonInteractive -File path\to\sync.ps1

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.