Variable current date folder name for Windows command?

Wow ! Many thanks albertony. You don't know how much it helped me! I much appreciated! :wink:
I went for your solution with Powershell, and it finally worked like a charm. :wink:

As I have spent quite a few hours trying to understand this, here is what I have done in case it can help someone else (with explanations on how to automate the script with Windows Task scheduler) :

(Assuming you have already Powershell installed on your computer)
I have created a txt file. I renamed it test.ps1
Then right-click on the "test.ps1" file and select open

Then paste the code :
In fact, do not use this one! :

.\rclone --checksum -vv copy GoogleDrive:Kv/$((Get-Date).ToString("yyyy\/yyyy-MM"))av GoogleSuite:1/Kv/$((Get-Date).ToString("yyyy\/yyyy-MM"))av

Use this one :wink: : (add the path where your rclone.exe is located, otherwise it won't load latter on with Windows Task scheduler! And I have also added the log info into a local log file. Like that, I can be sure that it has run)

C:\prog\rclone\rclone.exe --checksum -vv copy GoogleDrive:Kv/$((Get-Date).ToString("yyyy\/yyyy-MM"))av GoogleSuite:1/Kv/$((Get-Date).ToString("yyyy\/yyyy-MM"))av --log-file="C:\prog\rclone\mylogfile.txt"

Save the file and run it (F5).

Then add a Windows Task schedule to it (see image 2021-08-28-162159.png ):
Program :
powershell
Add arguments :
-NoLogo -NoProfile -NonInteractive -File "C:\prog\rclone\Kv.ps1"
(please notice the quotes after File as I had this problem)

Helping sources : How can I write batch sync command with a timestamp log file in Windows 10? - #2 by albertony
How to Automate PowerShell Scripts with Task Scheduler
I have also added log to the rclone command see here : How to generate log file for rclone? - #2 by thestigma

Again many thanks to albertony :wink: and also jojothehumanmonkey :wink:

1 Like