I am trying to get a batch going to backup a folder on a work server. (Please see attached link) Bat Error "invalid number of parameters"
Long story short - I need the script to name a new folder for each backup, which "md new_folder" was suggested, but I cannot seem to get the context or how to place it into the code.
@echo This will now create a new backup of S:\Internal Auditor\9 - September 14
@echo off
:: variables
set SRCFOLDER="S:\Internal Auditor\9 - September 14"
set DESTFOLDER="S:\Internal Auditor\2014\9 - Sept Backup"
set folder=%date:~5,2%-%date:~8,2%-%date:~0,4%
set backupcmd=/W /E /H /V /C /Z /I /F /J /R /Y
echo ######## PLEASE WAIT SYSTEM BACKINGUP SOME DATA########
"md new_folder" xcopy %SRCFOLDER% %DESTFOLDER% %backupcmd%
echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!!
@pause
Any help would be greatly appreciated!
----------EDIT: I tried a line of code that slowly got me closer:----------
@echo This will now create a new backup of S:\Internal Auditor\9 - September 14
@echo off
:: variables
set SRCFOLDER="S:\Internal Auditor\9 - September 14"
set DESTFOLDER="S:\Internal Auditor\2014\9 - Sept Backup"
set folder=%date:~5,2%-%date:~8,2%-%date:~0,4%
md "%DESTFOLDER%\%folder%"
set backupcmd=/W /E /H /V /C /Z /I /F /J /R /Y
echo ######## PLEASE WAIT SYSTEM BACKING UP SOME DATA########
xcopy %SRCFOLDER% "%DESTFOLDER%\%folder%" %backupcmd%
echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!!
@pause
BUT - I am getting the following output:
This will now create a new backup of S:\Internal Auditor\9 - September 14
Access is denied.
Error occurred while processing: S:\Internal.
A subdirectory or file Auditor\2014\9 already exists.
Error occurred while processing: Auditor\2014\9.
A subdirectory or file - already exists.
Error occurred while processing: -.
A subdirectory or file Sept already exists.
Error occurred while processing: Sept.
A subdirectory or file Backup\9/-9/-Tue already exists.
Error occurred while processing: Backup\9/-9/-Tue .
######## PLEASE WAIT SYSTEM BACKING UP SOME DATA########
Invalid number of parameters
!!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!!
Press any key to continue . . .
----------EDIT 2: I tried a line of code that slowly got me closer:----------
I have followed the suggestions and some things I found online, and now I am to the point where I am getting a few errors:
md "S:\Internal Auditor\~\09/12/2014"
A subdirectory or file S:\Internal Auditor\~\09/12/2014 already exists.
And:
xcopy "S:\Internal Auditor\9 - September 14 S:\Internal Auditor\2014\9 - Sept Backup\09/12/2014
/W /E /H /V /C /Z /I /F /J /R /Y /D
File not found - 09/12/2014 /W /E /H /V /C /Z /I /F /J /R /Y /D
This is my code:
@echo This will now create a new backup of S:\Internal Auditor\9 - September 14
Rem Backup 9 - September 14
@echo
:: variables
set "SRCFOLDER=S:\Internal Auditor\9 - September 14"
set "DESTFOLDER=S:\Internal Auditor\2014\9 - Sept Backup"
set folder=%date:~4%
md "%DESTFOLDER%\%folder%"
set backupcmd=/W /E /H /V /C /Z /I /F /J /R /Y /D
@echo ######## PLEASE WAIT SYSTEM BACKING UP SOME DATA########
xcopy "%SRCFOLDER% %DESTFOLDER%\%folder% %backupcmd%"
@echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!!
@pause
Also, when I run the code, it makes a new directory ~\09\12\2014 instead of the desired ~\09/12/2014. Clarification: It makes 3 new subdirectories instead of one new subdirectory.