Hi,
I have created a batch which will copy the contents(sub folders and files) of an existing folder with a specific name (folder name : "BackupFrom")from c:\ drive and create a new folder with a prefix "SampleRetentionBackup" followed by the
date time stamp in "yyyy_mm_dd" format like "SampleRetentionBackup_2018_11_28". After, copying i am looking for the same folder SampleRetentionBackup_2018_11_28" which are 1 days old and moving that folder(s) alone to a new folder
in d:\Archive where the Archive folder is created on the fly and move the folders which starts with "SampleRetentionBackup". So far it is working fine. But the only issue is instead of moving the folder which are x days old("SampleRetentionBackup_2018_11_28"),
it is moving the recent folder ("SampleRetentionBackup_2018_12_07")to the archive folder in d:\drive. I need some help.
Please find the batch file scripting below:
@echo off
cd c:\
set source=SampleRetentionBackup_%date:~10,4%_%date:~4,2%_%date:~7,2%
mkdir %source%
robocopy C:\BackupFrom %source% *.* /S
set destination=SampleRetentionBackup_%date:~10,4%_%date:~4,2%_%date:~7,2%
mkdir %destination%
if not exist d:\Archive\%destination% mkdir d:\Archive\%destination%
cd d:\Archive\%destination%
robocopy %source% /s /e /minage:2 /move d:\Archive\%destination%