trebor97351
trebor97351

Reputation: 3

what's wrong with my .bat file?

I'm trying to xcopy a folder with all sub folders and files into another folder which is named as the current date and time

This is what I have:

xcopy  C:\Users\t\Desktop\survival\world "C:\Users\t\Desktop\backups\survival\Backup-%date:/=/%_%time:~0,2%:%time:~3,2% /s /e /i

can anyone help me? thanks

Upvotes: 0

Views: 41

Answers (1)

MC ND
MC ND

Reputation: 70951

%time:~0,2%:%time:~3,2%
           ^....You can not have a colon in a file name

Also, you are missing a closing quote at the end of the target folder

@echo off
    setlocal enableextensions disabledelayedexpansion 

    set "source=C:\Users\t\Desktop\survival\world"
    set "target=C:\Users\t\Desktop\backups\survival\Backup"

:loop
    set "timeStamp=%date:/=/%_%time:~0,2%:%time:~3,2%"
    xcopy "%source%\." "%target%-%timeStamp%" /s /e /i
    ping -n 601 "" >nul 
    goto :loop

Upvotes: 1

Related Questions