Thanks to all! I found an error in the script which I ran multiple times on the command line. However I do have another problem. The script copies my a directory to a network drive. Works OK, however, the top directory I created on the NAS does not show up, only the second level. However, when I delete the content under the top directory I created it shows backup up. Any idea why this is happening?
@ECHO OFF
set d=R:
rem
rem map network drive
net use %d% /d /y
rem
rem map network drive
net use %d% "\\RND4250\hp-dv71245dx\Daily Backups"
rem
rem generate directory name
set h=%time:~0,2%
IF %time:~0,2% LSS 10 (set h=0%time:~1,1%)
set m=%time:~3,2%
set dirname=%date:~10,4%-%date:~4,2%-%date:~7,2%
rem
rem change drive & directory
%d%
rem
rem create directory
IF EXIST %dirname% (Set dirname=%dirname%-%h%%m%)
mkdir %dirname%
rem
rem generate robocopy command
set from=C:\Users\Steve\Documents
set to=%d%\%dirname%
robocopy "%from%" "%to%" /E /COPY:DAT /R:10 /Z /XJD /log:%d%\RoboCopyLog.txt
rem
rem unmap network drive
net use %d% /d /y
exit