Hello
I’ve been using the “xcopy” command in a batch file to backup the contents in a folder. I use task schedule to back up these files each day and backup what has changed from the previous backup.
Now I need to backup these files each day to a new folder so I can retain the data in the previous folder.
For example if I wanted to backup
C:\data to D:\data and I wanted to retain the data located in d:\data folder during the next backup.
How would I configure the batch file to create a new folder the next time the backup starts.
For example c:\data to d:\data_1
Thanks for helping
Xcopy batch file that creates new folder
Moderator: DosItHelp
-
- Posts: 8
- Joined: 11 Apr 2022 09:33
- Location: Italy
- Contact:
Re: Xcopy batch file that creates new folder
I'd use the date variable to create a UNIQUE backup everytime.
If you want to just use numbers you could go like:
So, if the folder data_1 already exist, the new folder will be called data_2... and so on.
Bye
If you want to just use numbers you could go like:
Code: Select all
@echo off
::assign new number
:newnumber
set /a counter+=1
if exist d:\data_%counter% goto :newnumber
::execute backup
xcopy /e c:\data d:\data_%counter%
Bye